Represents a time interval. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type. More...

Public Member Functions

constexpr TimeSpan ()
 Constructs a TimeSpan object that represents a zero time interval. More...
 
constexpr TimeSpan (int64_t ticks)
 Constructs an instance of TimeSpan class that represents the specified time interval. More...
 
ASPOSECPP_SHARED_API TimeSpan (int hours, int minutes, int seconds)
 Constructs an instance of TimeSpan class that represents the time interval which is equal to the sum of the specified number of hours, minutes and seconds. More...
 
ASPOSECPP_SHARED_API TimeSpan (int days, int hours, int minutes, int seconds, int milliseconds=0)
 Constructs an instance of TimeSpan class that represents the time interval which is equal to the sum of the specified number of hours, minutes, seconds and milliseconds. More...
 
constexpr TimeSpan (const TimeSpan &)=default
 Constructs a TimeSpan object that represents the time interval equal to the time interval represented by the specified TimeSpan object. More...
 
constexpr TimeSpanoperator= (const TimeSpan &)=default
 Sets the time interval represented by the specified TimeSpan object to the current TimeSpan object. More...
 
constexpr int CompareTo (TimeSpan value) const
 Compares current and the specified objects. More...
 
ASPOSECPP_SHARED_API int CompareTo (const SharedPtr< Object > &obj) const
 Compares current and the specified objects. More...
 
constexpr bool Equals (TimeSpan value) const
 Determines if the time interval represented by the current object is equal to the time interval represented by the specified object. More...
 
ASPOSECPP_SHARED_API bool Equals (const SharedPtr< Object > &obj) const
 Determines if the time interval represented by the current object is equal to the time interval represented by the specified object. More...
 
ASPOSECPP_SHARED_API int GetHashCode () const
 Returns a hash code for the current object. More...
 
constexpr int get_Days () const
 Returns the days component of the time interval represented by the current TimeSpan object. More...
 
constexpr int get_Hours () const
 Returns the hours component of the time interval represented by the current TimeSpan object. More...
 
constexpr int get_Minutes () const
 Returns the minutes component of the time interval represented by the current TimeSpan object. More...
 
constexpr int get_Seconds () const
 Returns the seconds component of the time interval represented by the current TimeSpan object. More...
 
constexpr int get_Milliseconds () const
 Returns the milliseconds component of the time interval represented by the current TimeSpan object. More...
 
constexpr int64_t get_Ticks () const
 Returns the number of 100-nanoseconds intervals that constitute the time interval represented by the current TimeSpan object. More...
 
constexpr double get_TotalDays () const
 Returns the value of the current TimeSpan object expressed in whole and fractional days. More...
 
constexpr double get_TotalHours () const
 Returns the value of the current TimeSpan object expressed in whole and fractional hours. More...
 
constexpr double get_TotalMinutes () const
 Returns the value of the current TimeSpan object expressed in whole and fractional minutes. More...
 
constexpr double get_TotalSeconds () const
 Returns the value of the current TimeSpan object expressed in whole and fractional seconds. More...
 
ASPOSECPP_SHARED_API double get_TotalMilliseconds () const
 Returns the value of the current TimeSpan object expressed in whole and fractional milliseconds. More...
 
ASPOSECPP_SHARED_API TimeSpan Add (TimeSpan value) const
 Returns a new instance of TimeSpan class that represents a time interval which is the sum of the time intervals represented by the current and the specified objects. More...
 
ASPOSECPP_SHARED_API TimeSpan Subtract (TimeSpan value) const
 Returns a new instance of TimeSpan class that represents a time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object. More...
 
ASPOSECPP_SHARED_API TimeSpan Negate () const
 Returns a new instance of TimeSpan object that represents negated value represented by the current TimeSpan object. More...
 
ASPOSECPP_SHARED_API TimeSpan Duration () const
 Returns a new instance of TimeSpan object whose value is the absolute value of the current object. More...
 
ASPOSECPP_SHARED_API String ToString () const
 Returns the string representation of the time interval represented by the current object. More...
 
ASPOSECPP_SHARED_API String ToString (const String &format) const
 Converts the value of the current object to equivalent string representation, using the specified format. More...
 
ASPOSECPP_SHARED_API String ToString (const String &format, const SharedPtr< IFormatProvider > &provider) const
 Converts the value of the current object to equivalent string representation, using the specified format and format provider. More...
 
ASPOSECPP_SHARED_API String ToString (const String &format, const SharedPtr< Globalization::CultureInfo > &culture) const
 
ASPOSECPP_SHARED_API String ToString (const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi) const
 
String ToString (const String &format, std::nullptr_t) const
 
TimeSpan operator+ (TimeSpan value) const
 Returns a new instance of TimeSpan class that represents a time interval which is the sum of the time intervals represented by the current and the specified objects. More...
 
TimeSpanoperator+= (TimeSpan value)
 Assigns to the current object the time interval which is the sum of the time interval represented by the current and the specified objects. More...
 
TimeSpan operator- (TimeSpan value) const
 Returns a new instance of TimeSpan class that represents a time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object. More...
 
TimeSpanoperator-= (TimeSpan value)
 Assigns to the current object the time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object. More...
 
TimeSpan operator- () const
 Returns a new instance of TimeSpan object that represents negated value represented by the current TimeSpan object. More...
 
TimeSpan operator+ () const
 Returns self. More...
 
ASPOSECPP_SHARED_API TimeSpan operator/ (double divisor) const
 
TimeSpanoperator/= (double divisor)
 
constexpr double operator/ (TimeSpan value) const
 
constexpr bool operator== (TimeSpan value) const
 Determines if the time interval represented by the current object is equal to the time interval represented by the specified object. More...
 
constexpr bool operator!= (TimeSpan value) const
 Determines if the time interval represented by the current object is not equal to the time interval represented by the specified object. More...
 
constexpr bool operator< (TimeSpan value) const
 Determines if the time interval represented by the current object is shorter than the time interval represented by the specified object. More...
 
constexpr bool operator<= (TimeSpan value) const
 Determines if the time interval represented by the current object is shorter than or equal to the time interval represented by the specified object. More...
 
constexpr bool operator> (TimeSpan value) const
 Determines if the time interval represented by the current object is longer than the time interval represented by the specified object. More...
 
constexpr bool operator>= (TimeSpan value) const
 Determines if the time interval represented by the current object is longer than or equal to the time interval represented by the specified object. More...
 
constexpr bool IsNull () const
 
constexpr bool operator== (std::nullptr_t) const
 
constexpr bool operator!= (std::nullptr_t) const
 
constexpr bool operator< (std::nullptr_t) const
 
constexpr bool operator<= (std::nullptr_t) const
 
constexpr bool operator> (std::nullptr_t) const
 
constexpr bool operator>= (std::nullptr_t) const
 

Static Public Member Functions

static constexpr TimeSpan FromTicks (int64_t ticks)
 Returns a new TimeSpan object that represents the specified interval. More...
 
static TimeSpan FromMilliseconds (double value)
 Returns a new TimeSpan object that represents the specified interval. More...
 
static TimeSpan FromSeconds (double value)
 Returns a new TimeSpan object that represents the specified interval. More...
 
static TimeSpan FromMinutes (double value)
 Returns a new TimeSpan object that represents the specified interval. More...
 
static TimeSpan FromHours (double value)
 Returns a new TimeSpan object that represents the specified interval. More...
 
static TimeSpan FromDays (double value)
 Returns a new TimeSpan object that represents the specified interval. More...
 
static constexpr int Compare (TimeSpan t1, TimeSpan t2)
 Compares two TimeSpan objects. More...
 
static constexpr bool Equals (TimeSpan a, TimeSpan b)
 Returns true if the specified objects represent the same time interval, otherwise - false. More...
 
static ASPOSECPP_SHARED_API TimeSpan Parse (const String &input)
 Converts string to equivalent TimeSpan object. More...
 
static ASPOSECPP_SHARED_API TimeSpan Parse (const String &input, const SharedPtr< IFormatProvider > &provider)
 Converts string to equivalent TimeSpan object using the specified format provider. More...
 
static ASPOSECPP_SHARED_API TimeSpan Parse (const String &input, const SharedPtr< Globalization::CultureInfo > &culture)
 
static ASPOSECPP_SHARED_API TimeSpan Parse (const String &input, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi)
 
static TimeSpan Parse (const String &input, std::nullptr_t)
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< IFormatProvider > &provider, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 Converts string to equivalent TimeSpan object using the specified formats, format provider and styles. More...
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const ArrayPtr< String > &formats, std::nullptr_t, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const String &format, const SharedPtr< IFormatProvider > &provider, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 Converts string to equivalent TimeSpan object using the specified format, format provider and styles. More...
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const String &format, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 
static ASPOSECPP_SHARED_API TimeSpan ParseExact (const String &input, const String &format, std::nullptr_t, Globalization::TimeSpanStyles styles=Globalization::TimeSpanStyles::None)
 
static ASPOSECPP_SHARED_API bool TryParse (const String &input, TimeSpan &result)
 Converts string to equivalent TimeSpan object and returns result of conversion. More...
 
static ASPOSECPP_SHARED_API bool TryParse (const String &input, const SharedPtr< IFormatProvider > &provider, TimeSpan &result)
 Converts string to equivalent TimeSpan object using the specified format provider and returns result of conversion. More...
 
static ASPOSECPP_SHARED_API bool TryParse (const String &input, const SharedPtr< Globalization::CultureInfo > &culture, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParse (const String &input, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParse (const String &input, std::nullptr_t, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< IFormatProvider > &provider, TimeSpan &result)
 Converts string to equivalent TimeSpan object using the specified formats and format provider, and returns result of conversion. More...
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< Globalization::CultureInfo > &culture, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, std::nullptr_t, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, const SharedPtr< IFormatProvider > &provider, Globalization::TimeSpanStyles styles, TimeSpan &result)
 Converts string to equivalent TimeSpan object using the specified format, format provider and styles, and returns result of conversion. More...
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::TimeSpanStyles styles, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::TimeSpanStyles styles, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, std::nullptr_t, Globalization::TimeSpanStyles styles, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< IFormatProvider > &provider, Globalization::TimeSpanStyles styles, TimeSpan &result)
 Converts string to equivalent TimeSpan object using the specified formats, format provider and styles, and returns result of conversion. More...
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::TimeSpanStyles styles, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::TimeSpanStyles styles, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const ArrayPtr< String > &formats, std::nullptr_t, Globalization::TimeSpanStyles styles, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, const SharedPtr< IFormatProvider > &provider, TimeSpan &result)
 Converts string to equivalent TimeSpan object using the specified format and format provider, and returns result of conversion. More...
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, const SharedPtr< Globalization::CultureInfo > &culture, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, TimeSpan &result)
 
static ASPOSECPP_SHARED_API bool TryParseExact (const String &input, const String &format, std::nullptr_t, TimeSpan &result)
 
static const TypeInfoType ()
 Returns a TypeInfo object that represent TimeSpan structure. More...
 

Static Public Attributes

static ASPOSECPP_SHARED_API const TimeSpan Zero
 The TimeSpan object that represents zero-interval. More...
 
static ASPOSECPP_SHARED_API const TimeSpan MaxValue
 The TimeSpan object that represents the longest possible interval. More...
 
static ASPOSECPP_SHARED_API const TimeSpan MinValue
 /// The TimeSpan object that represents the shortest possible interval. More...
 
static constexpr int64_t TicksPerDay = 864000000000ULL
 The number of 100-nanoseconds intervals in a day (24-hour interval). More...
 
static constexpr int64_t TicksPerHour = 36000000000ULL
 The number of 100-nanoseconds intervals in a hour. More...
 
static constexpr int64_t TicksPerMillisecond = 10000ULL
 The number of 100-nanoseconds intervals in a millisecond. More...
 
static constexpr int64_t TicksPerMinute = 600000000ULL
 The number of 100-nanoseconds intervals in a minute. More...
 
static constexpr int64_t TicksPerSecond = 10000000ULL
 The number of 100-nanoseconds intervals in a second. More...
 

Detailed Description

Represents a time interval. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

#include "system/datetime.h"
#include "system/timespan.h"
#include <iostream>
int main()
{
const auto date1 = System::DateTime(2021, 01, 01);
const auto date2 = System::DateTime(2021, 10, 30);
const auto interval = date2 - date1;
std::cout << "Number of ticks: " << interval.get_Ticks() << std::endl;
std::cout << "Number of milliseconds: " << interval.get_Milliseconds() << std::endl;
std::cout << "Total number of milliseconds: " << interval.get_TotalMilliseconds() << std::endl;
std::cout << "Number of minutes: " << interval.get_Minutes() << std::endl;
std::cout << "Total number of minutes: " << interval.get_TotalMinutes() << std::endl;
std::cout << "Number of hours: " << interval.get_Hours() << std::endl;
std::cout << "Total number of hours: " << interval.get_Hours() << std::endl;
std::cout << "Number of days: " << interval.get_Days() << std::endl;
std::cout << "Total number of days: " << interval.get_TotalDays() << std::endl;
return 0;
}
/*
This code example produces the following output:
Number of ticks: 260928000000000
Number of milliseconds: 0
Total number of milliseconds: 2.60928e+10
Number of minutes: 0
Total number of minutes: 434880
Number of hours: 0
Total number of hours: 0
Number of days: 302
Total number of days: 302
*/

Constructor & Destructor Documentation

◆ TimeSpan() [1/5]

constexpr System::TimeSpan::TimeSpan ( )
inline

Constructs a TimeSpan object that represents a zero time interval.

◆ TimeSpan() [2/5]

constexpr System::TimeSpan::TimeSpan ( int64_t  ticks)
inlineexplicit

Constructs an instance of TimeSpan class that represents the specified time interval.

Parameters
ticksThe time interval to be represented by the instance being constructed expressed as the number of 100-nanoseconds intervals.

◆ TimeSpan() [3/5]

ASPOSECPP_SHARED_API System::TimeSpan::TimeSpan ( int  hours,
int  minutes,
int  seconds 
)

Constructs an instance of TimeSpan class that represents the time interval which is equal to the sum of the specified number of hours, minutes and seconds.

Parameters
hoursThe number of hours in the hours component of the time interval to be represented by the instance being constructed
minutesThe number of minutes in the minutes component of the time interval to be represented by the instance being constructed
secondsThe number of seconds in the seconds component of the time interval to be represented by the instance being constructed

◆ TimeSpan() [4/5]

ASPOSECPP_SHARED_API System::TimeSpan::TimeSpan ( int  days,
int  hours,
int  minutes,
int  seconds,
int  milliseconds = 0 
)

Constructs an instance of TimeSpan class that represents the time interval which is equal to the sum of the specified number of hours, minutes, seconds and milliseconds.

Parameters
daysThe number of days in the days component of the time interval to be represented by the instance being constructed
hoursThe number of hours in the hours component of the time interval to be represented by the instance being constructed
minutesThe number of minutes in the minutes component of the time interval to be represented by the instance being constructed
secondsThe number of seconds in the seconds component of the time interval to be represented by the instance being constructed
millisecondsThe number of milliseconds in the milliseconds component of the time interval to be represented by the instance being constructed

◆ TimeSpan() [5/5]

constexpr System::TimeSpan::TimeSpan ( const TimeSpan )
default

Constructs a TimeSpan object that represents the time interval equal to the time interval represented by the specified TimeSpan object.

Member Function Documentation

◆ Add()

ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Add ( TimeSpan  value) const

Returns a new instance of TimeSpan class that represents a time interval which is the sum of the time intervals represented by the current and the specified objects.

Parameters
valueThe TimeSpan object that represents the time interval to add
Returns
A new instance of TimeSpan class that represents a time interval which is the sum of the time intervals represented by the current and the specified objects.

◆ Compare()

static constexpr int System::TimeSpan::Compare ( TimeSpan  t1,
TimeSpan  t2 
)
inlinestatic

Compares two TimeSpan objects.

Parameters
t1The first comparand
t2The second comparand
Returns
-1 if t1 is shorter than t2; 0 if t1 is equal to t2; 1 if t1 is longer than t2

◆ CompareTo() [1/2]

constexpr int System::TimeSpan::CompareTo ( TimeSpan  value) const
inline

Compares current and the specified objects.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
-1 if the current object represents the interval that is shorter than value; 0 if the current object represents the interval that is equal to value; 1 if the current object represents the interval that is longer than value

◆ CompareTo() [2/2]

ASPOSECPP_SHARED_API int System::TimeSpan::CompareTo ( const SharedPtr< Object > &  obj) const

Compares current and the specified objects.

Parameters
objThe TimeSpan object to compare the current object with
Returns
-1 if the current object represents the interval that is shorter than value; 0 if the current object represents the interval that is equal to value; 1 if the current object represents the interval that is longer than value

◆ Duration()

ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Duration ( ) const

Returns a new instance of TimeSpan object whose value is the absolute value of the current object.

◆ Equals() [1/3]

constexpr bool System::TimeSpan::Equals ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is equal to the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the current object and the specified object represent the same time interval, otherwise - false

◆ Equals() [2/3]

ASPOSECPP_SHARED_API bool System::TimeSpan::Equals ( const SharedPtr< Object > &  obj) const

Determines if the time interval represented by the current object is equal to the time interval represented by the specified object.

Parameters
objThe TimeSpan object to compare the current object with
Returns
True if the current object and the specified object represent the same time interval, otherwise - false

◆ Equals() [3/3]

static constexpr bool System::TimeSpan::Equals ( TimeSpan  a,
TimeSpan  b 
)
inlinestatic

Returns true if the specified objects represent the same time interval, otherwise - false.

◆ FromDays()

static TimeSpan System::TimeSpan::FromDays ( double  value)
inlinestatic

Returns a new TimeSpan object that represents the specified interval.

Parameters
valueThe time interval expressed as the number of days.
Returns
A new TimeSpan object that represents the specified interval.

◆ FromHours()

static TimeSpan System::TimeSpan::FromHours ( double  value)
inlinestatic

Returns a new TimeSpan object that represents the specified interval.

Parameters
valueThe time interval expressed as the number of hours.
Returns
A new TimeSpan object that represents the specified interval.

◆ FromMilliseconds()

static TimeSpan System::TimeSpan::FromMilliseconds ( double  value)
inlinestatic

Returns a new TimeSpan object that represents the specified interval.

Parameters
valueThe time interval expressed as the number of milliseconds.
Returns
A new TimeSpan object that represents the specified interval.

◆ FromMinutes()

static TimeSpan System::TimeSpan::FromMinutes ( double  value)
inlinestatic

Returns a new TimeSpan object that represents the specified interval.

Parameters
valueThe time interval expressed as the number of minutes.
Returns
A new TimeSpan object that represents the specified interval.

◆ FromSeconds()

static TimeSpan System::TimeSpan::FromSeconds ( double  value)
inlinestatic

Returns a new TimeSpan object that represents the specified interval.

Parameters
valueThe time interval expressed as the number of seconds.
Returns
A new TimeSpan object that represents the specified interval.

◆ FromTicks()

static constexpr TimeSpan System::TimeSpan::FromTicks ( int64_t  ticks)
inlinestatic

Returns a new TimeSpan object that represents the specified interval.

Parameters
ticksThe time interval expressed as the number of 100-nanoseconds intervals.
Returns
A new TimeSpan object that represents the specified interval.

◆ get_Days()

constexpr int System::TimeSpan::get_Days ( ) const
inline

Returns the days component of the time interval represented by the current TimeSpan object.

◆ get_Hours()

constexpr int System::TimeSpan::get_Hours ( ) const
inline

Returns the hours component of the time interval represented by the current TimeSpan object.

◆ get_Milliseconds()

constexpr int System::TimeSpan::get_Milliseconds ( ) const
inline

Returns the milliseconds component of the time interval represented by the current TimeSpan object.

◆ get_Minutes()

constexpr int System::TimeSpan::get_Minutes ( ) const
inline

Returns the minutes component of the time interval represented by the current TimeSpan object.

◆ get_Seconds()

constexpr int System::TimeSpan::get_Seconds ( ) const
inline

Returns the seconds component of the time interval represented by the current TimeSpan object.

◆ get_Ticks()

constexpr int64_t System::TimeSpan::get_Ticks ( ) const
inline

Returns the number of 100-nanoseconds intervals that constitute the time interval represented by the current TimeSpan object.

◆ get_TotalDays()

constexpr double System::TimeSpan::get_TotalDays ( ) const
inline

Returns the value of the current TimeSpan object expressed in whole and fractional days.

◆ get_TotalHours()

constexpr double System::TimeSpan::get_TotalHours ( ) const
inline

Returns the value of the current TimeSpan object expressed in whole and fractional hours.

◆ get_TotalMilliseconds()

ASPOSECPP_SHARED_API double System::TimeSpan::get_TotalMilliseconds ( ) const

Returns the value of the current TimeSpan object expressed in whole and fractional milliseconds.

◆ get_TotalMinutes()

constexpr double System::TimeSpan::get_TotalMinutes ( ) const
inline

Returns the value of the current TimeSpan object expressed in whole and fractional minutes.

◆ get_TotalSeconds()

constexpr double System::TimeSpan::get_TotalSeconds ( ) const
inline

Returns the value of the current TimeSpan object expressed in whole and fractional seconds.

◆ GetHashCode()

ASPOSECPP_SHARED_API int System::TimeSpan::GetHashCode ( ) const

Returns a hash code for the current object.

◆ IsNull()

constexpr bool System::TimeSpan::IsNull ( ) const
inline

◆ Negate()

ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Negate ( ) const

Returns a new instance of TimeSpan object that represents negated value represented by the current TimeSpan object.

◆ operator!=() [1/2]

constexpr bool System::TimeSpan::operator!= ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is not equal to the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the current object and the specified object represent different time intervals, otherwise - false

◆ operator!=() [2/2]

constexpr bool System::TimeSpan::operator!= ( std::nullptr_t  ) const
inline

◆ operator+() [1/2]

TimeSpan System::TimeSpan::operator+ ( TimeSpan  value) const
inline

Returns a new instance of TimeSpan class that represents a time interval which is the sum of the time intervals represented by the current and the specified objects.

Parameters
valueThe TimeSpan object that represents the time interval to add
Returns
A new instance of TimeSpan class that represents a time interval which is the sum of the time intervals represented by the current and the specified objects.

◆ operator+() [2/2]

TimeSpan System::TimeSpan::operator+ ( ) const
inline

Returns self.

◆ operator+=()

TimeSpan& System::TimeSpan::operator+= ( TimeSpan  value)
inline

Assigns to the current object the time interval which is the sum of the time interval represented by the current and the specified objects.

Parameters
valueThe TimeSpan object that represents the time interval to add
Returns
A reference to the self

◆ operator-() [1/2]

TimeSpan System::TimeSpan::operator- ( TimeSpan  value) const
inline

Returns a new instance of TimeSpan class that represents a time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object.

Parameters
valueThe TimeSpan object that represents the time interval to subtract
Returns
A new instance of TimeSpan class that represents a time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object.

◆ operator-() [2/2]

TimeSpan System::TimeSpan::operator- ( ) const
inline

Returns a new instance of TimeSpan object that represents negated value represented by the current TimeSpan object.

◆ operator-=()

TimeSpan& System::TimeSpan::operator-= ( TimeSpan  value)
inline

Assigns to the current object the time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object.

Parameters
valueThe TimeSpan object that represents the time interval to subtract
Returns
A reference to the self

◆ operator/() [1/2]

ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::operator/ ( double  divisor) const

◆ operator/() [2/2]

constexpr double System::TimeSpan::operator/ ( TimeSpan  value) const
inline

◆ operator/=()

TimeSpan& System::TimeSpan::operator/= ( double  divisor)
inline

◆ operator<() [1/2]

constexpr bool System::TimeSpan::operator< ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is shorter than the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the time interval represented by the current object is shorter than the time interval represented by value, otherwise - false

◆ operator<() [2/2]

constexpr bool System::TimeSpan::operator< ( std::nullptr_t  ) const
inline

◆ operator<=() [1/2]

constexpr bool System::TimeSpan::operator<= ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is shorter than or equal to the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the time interval represented by the current object is shorter than or equal to the time interval represented by value, otherwise - false

◆ operator<=() [2/2]

constexpr bool System::TimeSpan::operator<= ( std::nullptr_t  ) const
inline

◆ operator=()

constexpr TimeSpan& System::TimeSpan::operator= ( const TimeSpan )
default

Sets the time interval represented by the specified TimeSpan object to the current TimeSpan object.

Returns
A reference to the self

◆ operator==() [1/2]

constexpr bool System::TimeSpan::operator== ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is equal to the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the current object and the specified object represent the same time interval, otherwise - false

◆ operator==() [2/2]

constexpr bool System::TimeSpan::operator== ( std::nullptr_t  ) const
inline

◆ operator>() [1/2]

constexpr bool System::TimeSpan::operator> ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is longer than the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the time interval represented by the current object is longer than the time interval represented by value, otherwise - false

◆ operator>() [2/2]

constexpr bool System::TimeSpan::operator> ( std::nullptr_t  ) const
inline

◆ operator>=() [1/2]

constexpr bool System::TimeSpan::operator>= ( TimeSpan  value) const
inline

Determines if the time interval represented by the current object is longer than or equal to the time interval represented by the specified object.

Parameters
valueThe TimeSpan object to compare the current object with
Returns
True if the time interval represented by the current object is longer than or equal to the time interval represented by value, otherwise - false

◆ operator>=() [2/2]

constexpr bool System::TimeSpan::operator>= ( std::nullptr_t  ) const
inline

◆ Parse() [1/5]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Parse ( const String input)
static

Converts string to equivalent TimeSpan object.

Parameters
inputInput string.
Returns
Time interval that corresponds to string.

◆ Parse() [2/5]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Parse ( const String input,
const SharedPtr< IFormatProvider > &  provider 
)
static

Converts string to equivalent TimeSpan object using the specified format provider.

Parameters
inputInput string.
providerFormat provider that supplies culture-specific formatting information.
Returns
Time interval that corresponds to string.

◆ Parse() [3/5]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Parse ( const String input,
const SharedPtr< Globalization::CultureInfo > &  culture 
)
static

◆ Parse() [4/5]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Parse ( const String input,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi 
)
static

◆ Parse() [5/5]

static TimeSpan System::TimeSpan::Parse ( const String input,
std::nullptr_t   
)
inlinestatic

◆ ParseExact() [1/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< IFormatProvider > &  provider,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

Converts string to equivalent TimeSpan object using the specified formats, format provider and styles.

Parameters
inputInput string.
formatsArray of format strings.
providerFormat provider that supplies culture-specific formatting information.
stylesDefines elements that may be present in input string.
Returns
Time interval that corresponds to string.

◆ ParseExact() [2/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< Globalization::CultureInfo > &  culture,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

◆ ParseExact() [3/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

◆ ParseExact() [4/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const ArrayPtr< String > &  formats,
std::nullptr_t  ,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

◆ ParseExact() [5/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const String format,
const SharedPtr< IFormatProvider > &  provider,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

Converts string to equivalent TimeSpan object using the specified format, format provider and styles.

Parameters
inputInput string.
formatStandard or custom format string.
providerFormat provider that supplies culture-specific formatting information.
stylesDefines elements that may be present in input string.
Returns
Time interval that corresponds to string.

◆ ParseExact() [6/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const String format,
const SharedPtr< Globalization::CultureInfo > &  culture,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

◆ ParseExact() [7/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const String format,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

◆ ParseExact() [8/8]

static ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::ParseExact ( const String input,
const String format,
std::nullptr_t  ,
Globalization::TimeSpanStyles  styles = Globalization::TimeSpanStyles::None 
)
static

◆ Subtract()

ASPOSECPP_SHARED_API TimeSpan System::TimeSpan::Subtract ( TimeSpan  value) const

Returns a new instance of TimeSpan class that represents a time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object.

Parameters
valueThe TimeSpan object that represents the time interval to subtract
Returns
A new instance of TimeSpan class that represents a time interval which is the result of subtraction of the time interval represented by the specified object from the time interval represented by the current object.

◆ ToString() [1/6]

ASPOSECPP_SHARED_API String System::TimeSpan::ToString ( ) const

Returns the string representation of the time interval represented by the current object.

◆ ToString() [2/6]

ASPOSECPP_SHARED_API String System::TimeSpan::ToString ( const String format) const

Converts the value of the current object to equivalent string representation, using the specified format.

◆ ToString() [3/6]

ASPOSECPP_SHARED_API String System::TimeSpan::ToString ( const String format,
const SharedPtr< IFormatProvider > &  provider 
) const

Converts the value of the current object to equivalent string representation, using the specified format and format provider.

◆ ToString() [4/6]

ASPOSECPP_SHARED_API String System::TimeSpan::ToString ( const String format,
const SharedPtr< Globalization::CultureInfo > &  culture 
) const

◆ ToString() [5/6]

ASPOSECPP_SHARED_API String System::TimeSpan::ToString ( const String format,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi 
) const

◆ ToString() [6/6]

String System::TimeSpan::ToString ( const String format,
std::nullptr_t   
) const
inline

◆ TryParse() [1/5]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParse ( const String input,
TimeSpan result 
)
static

Converts string to equivalent TimeSpan object and returns result of conversion.

Parameters
inputInput string.
resultTime interval that corresponds to string.
Returns
True if string was converted successfully; otherwise, false.

◆ TryParse() [2/5]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParse ( const String input,
const SharedPtr< IFormatProvider > &  provider,
TimeSpan result 
)
static

Converts string to equivalent TimeSpan object using the specified format provider and returns result of conversion.

Parameters
inputInput string.
providerFormat provider that supplies culture-specific formatting information.
resultTime interval that corresponds to string.
Returns
True if string was converted successfully; otherwise, false.

◆ TryParse() [3/5]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParse ( const String input,
const SharedPtr< Globalization::CultureInfo > &  culture,
TimeSpan result 
)
static

◆ TryParse() [4/5]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParse ( const String input,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
TimeSpan result 
)
static

◆ TryParse() [5/5]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParse ( const String input,
std::nullptr_t  ,
TimeSpan result 
)
static

◆ TryParseExact() [1/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< IFormatProvider > &  provider,
TimeSpan result 
)
static

Converts string to equivalent TimeSpan object using the specified formats and format provider, and returns result of conversion.

Parameters
inputInput string.
formatsArray of format strings.
providerFormat provider that supplies culture-specific formatting information.
resultTime interval that corresponds to string.
Returns
True if string was converted successfully; otherwise, false.

◆ TryParseExact() [2/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< Globalization::CultureInfo > &  culture,
TimeSpan result 
)
static

◆ TryParseExact() [3/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
TimeSpan result 
)
static

◆ TryParseExact() [4/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
std::nullptr_t  ,
TimeSpan result 
)
static

◆ TryParseExact() [5/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
const SharedPtr< IFormatProvider > &  provider,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

Converts string to equivalent TimeSpan object using the specified format, format provider and styles, and returns result of conversion.

Parameters
inputInput string.
formatStandard or custom format string.
providerFormat provider that supplies culture-specific formatting information.
stylesDefines elements that may be present in input string.
resultTime interval that corresponds to string.
Returns
True if string was converted successfully; otherwise, false.

◆ TryParseExact() [6/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
const SharedPtr< Globalization::CultureInfo > &  culture,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

◆ TryParseExact() [7/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

◆ TryParseExact() [8/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
std::nullptr_t  ,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

◆ TryParseExact() [9/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< IFormatProvider > &  provider,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

Converts string to equivalent TimeSpan object using the specified formats, format provider and styles, and returns result of conversion.

Parameters
inputInput string.
formatsArray of format strings.
providerFormat provider that supplies culture-specific formatting information.
stylesDefines elements that may be present in input string.
resultTime interval that corresponds to string.
Returns
True if string was converted successfully; otherwise, false.

◆ TryParseExact() [10/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< Globalization::CultureInfo > &  culture,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

◆ TryParseExact() [11/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

◆ TryParseExact() [12/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const ArrayPtr< String > &  formats,
std::nullptr_t  ,
Globalization::TimeSpanStyles  styles,
TimeSpan result 
)
static

◆ TryParseExact() [13/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
const SharedPtr< IFormatProvider > &  provider,
TimeSpan result 
)
static

Converts string to equivalent TimeSpan object using the specified format and format provider, and returns result of conversion.

Parameters
inputInput string.
formatStandard or custom format string.
providerFormat provider that supplies culture-specific formatting information.
resultTime interval that corresponds to string.
Returns
True if string was converted successfully; otherwise, false.

◆ TryParseExact() [14/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
const SharedPtr< Globalization::CultureInfo > &  culture,
TimeSpan result 
)
static

◆ TryParseExact() [15/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
const SharedPtr< Globalization::DateTimeFormatInfo > &  dtfi,
TimeSpan result 
)
static

◆ TryParseExact() [16/16]

static ASPOSECPP_SHARED_API bool System::TimeSpan::TryParseExact ( const String input,
const String format,
std::nullptr_t  ,
TimeSpan result 
)
static

◆ Type()

static const TypeInfo& System::TimeSpan::Type ( )
inlinestatic

Returns a TypeInfo object that represent TimeSpan structure.

Member Data Documentation

◆ MaxValue

ASPOSECPP_SHARED_API const TimeSpan System::TimeSpan::MaxValue
static

The TimeSpan object that represents the longest possible interval.

◆ MinValue

ASPOSECPP_SHARED_API const TimeSpan System::TimeSpan::MinValue
static

/// The TimeSpan object that represents the shortest possible interval.

◆ TicksPerDay

constexpr int64_t System::TimeSpan::TicksPerDay = 864000000000ULL
static

The number of 100-nanoseconds intervals in a day (24-hour interval).

◆ TicksPerHour

constexpr int64_t System::TimeSpan::TicksPerHour = 36000000000ULL
static

The number of 100-nanoseconds intervals in a hour.

◆ TicksPerMillisecond

constexpr int64_t System::TimeSpan::TicksPerMillisecond = 10000ULL
static

The number of 100-nanoseconds intervals in a millisecond.

◆ TicksPerMinute

constexpr int64_t System::TimeSpan::TicksPerMinute = 600000000ULL
static

The number of 100-nanoseconds intervals in a minute.

◆ TicksPerSecond

constexpr int64_t System::TimeSpan::TicksPerSecond = 10000000ULL
static

The number of 100-nanoseconds intervals in a second.

◆ Zero

ASPOSECPP_SHARED_API const TimeSpan System::TimeSpan::Zero
static

The TimeSpan object that represents zero-interval.