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...
|
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 TimeSpan & | operator= (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...
|
|
TimeSpan & | operator+= (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...
|
|
TimeSpan & | operator-= (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 |
|
TimeSpan & | operator/= (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 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 TypeInfo & | Type () |
| Returns a TypeInfo object that represent TimeSpan structure. More...
|
|
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 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;
}