TimeSpan
Contents
[
Hide
]TimeSpan class
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.
class TimeSpan
Methods
Method | Description |
---|---|
TimeSpan Add(TimeSpan) 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. |
static constexpr int Compare(TimeSpan, TimeSpan) | Compares two TimeSpan objects. |
constexpr int CompareTo(TimeSpan) const | Compares current and the specified objects. |
int CompareTo(const SharedPtr<Object>&) const | Compares current and the specified objects. |
TimeSpan Duration() const | Returns a new instance of TimeSpan object whose value is the absolute value of the current object. |
constexpr bool Equals(TimeSpan) const | Determines if the time interval represented by the current object is equal to the time interval represented by the specified object. |
bool Equals(const SharedPtr<Object>&) const | Determines if the time interval represented by the current object is equal to the time interval represented by the specified object. |
static constexpr bool Equals(TimeSpan, TimeSpan) | Returns true if the specified objects represent the same time interval, otherwise - false. |
static TimeSpan FromDays(double) | Returns a new TimeSpan object that represents the specified interval. |
static TimeSpan FromHours(double) | Returns a new TimeSpan object that represents the specified interval. |
static TimeSpan FromMilliseconds(double) | Returns a new TimeSpan object that represents the specified interval. |
static TimeSpan FromMinutes(double) | Returns a new TimeSpan object that represents the specified interval. |
static TimeSpan FromSeconds(double) | Returns a new TimeSpan object that represents the specified interval. |
static constexpr TimeSpan FromTicks(int64_t) | Returns a new TimeSpan object that represents the specified interval. |
constexpr int get_Days() const | Returns the days component of the time interval represented by the current TimeSpan object. |
constexpr int get_Hours() const | Returns the hours component of the time interval represented by the current TimeSpan object. |
constexpr int get_Milliseconds() const | Returns the milliseconds component of the time interval represented by the current TimeSpan object. |
constexpr int get_Minutes() const | Returns the minutes component of the time interval represented by the current TimeSpan object. |
constexpr int get_Seconds() const | Returns the seconds component of the time interval represented by the current TimeSpan object. |
constexpr int64_t get_Ticks() const | Returns the number of 100-nanoseconds intervals that constitute the time interval represented by the current TimeSpan object. |
constexpr double get_TotalDays() const | Returns the value of the current TimeSpan object expressed in whole and fractional days. |
constexpr double get_TotalHours() const | Returns the value of the current TimeSpan object expressed in whole and fractional hours. |
double get_TotalMilliseconds() const | Returns the value of the current TimeSpan object expressed in whole and fractional milliseconds. |
constexpr double get_TotalMinutes() const | Returns the value of the current TimeSpan object expressed in whole and fractional minutes. |
constexpr double get_TotalSeconds() const | Returns the value of the current TimeSpan object expressed in whole and fractional seconds. |
int GetHashCode() const | Returns a hash code for the current object. |
constexpr bool IsNull() const | |
TimeSpan Negate() const | Returns a new instance of TimeSpan object that represents negated value represented by the current TimeSpan object. |
constexpr bool operator!=(TimeSpan) const | Determines if the time interval represented by the current object is not equal to the time interval represented by the specified object. |
constexpr bool operator!=(std::nullptr_t) const | |
TimeSpan operator+(TimeSpan) 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. |
TimeSpan operator+() const | Returns self. |
TimeSpan& operator+=(TimeSpan) | Assigns to the current object the time interval which is the sum of the time interval represented by the current and the specified objects. |
TimeSpan operator-(TimeSpan) 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. |
TimeSpan operator-() const | Returns a new instance of TimeSpan object that represents negated value represented by the current TimeSpan object. |
TimeSpan& operator-=(TimeSpan) | 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. |
TimeSpan operator/(double) const | |
constexpr double operator/(TimeSpan) const | |
TimeSpan& operator/=(double) | |
constexpr bool operator<(TimeSpan) const | Determines if the time interval represented by the current object is shorter than the time interval represented by the specified object. |
constexpr bool operator<(std::nullptr_t) const | |
constexpr bool operator<=(TimeSpan) 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. |
constexpr bool operator<=(std::nullptr_t) const | |
constexpr TimeSpan& operator=(const TimeSpan&) | Sets the time interval represented by the specified TimeSpan object to the current TimeSpan object. |
constexpr bool operator==(TimeSpan) const | Determines if the time interval represented by the current object is equal to the time interval represented by the specified object. |
constexpr bool operator==(std::nullptr_t) const | |
constexpr bool operator>(TimeSpan) const | Determines if the time interval represented by the current object is longer than the time interval represented by the specified object. |
constexpr bool operator>(std::nullptr_t) const | |
constexpr bool operator>=(TimeSpan) 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. |
constexpr bool operator>=(std::nullptr_t) const | |
static TimeSpan Parse(const String&) | Converts string to equivalent TimeSpan object. |
static TimeSpan Parse(const String&, const SharedPtr<IFormatProvider>&) | Converts string to equivalent TimeSpan object using the specified format provider. |
static TimeSpan Parse(const String&, const SharedPtr<Globalization::CultureInfo>&) | |
static TimeSpan Parse(const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&) | |
static TimeSpan Parse(const String&, std::nullptr_t) | |
static TimeSpan ParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<IFormatProvider>&, Globalization::TimeSpanStyles) | Converts string to equivalent TimeSpan object using the specified formats, format provider and styles. |
static TimeSpan ParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::CultureInfo>&, Globalization::TimeSpanStyles) | |
static TimeSpan ParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::TimeSpanStyles) | |
static TimeSpan ParseExact(const String&, const ArrayPtr<String>&, std::nullptr_t, Globalization::TimeSpanStyles) | |
static TimeSpan ParseExact(const String&, const String&, const SharedPtr<IFormatProvider>&, Globalization::TimeSpanStyles) | Converts string to equivalent TimeSpan object using the specified format, format provider and styles. |
static TimeSpan ParseExact(const String&, const String&, const SharedPtr<Globalization::CultureInfo>&, Globalization::TimeSpanStyles) | |
static TimeSpan ParseExact(const String&, const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::TimeSpanStyles) | |
static TimeSpan ParseExact(const String&, const String&, std::nullptr_t, Globalization::TimeSpanStyles) | |
TimeSpan Subtract(TimeSpan) 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. |
constexpr TimeSpan() | Constructs a TimeSpan object that represents a zero time interval. |
explicit constexpr TimeSpan(int64_t) | Constructs an instance of TimeSpan class that represents the specified time interval. |
TimeSpan(int, int, int) | 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. |
TimeSpan(int, int, int, int, int) | 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. |
constexpr TimeSpan(const TimeSpan&) | Constructs a TimeSpan object that represents the time interval equal to the time interval represented by the specified TimeSpan object. |
String ToString() const | Returns the string representation of the time interval represented by the current object. |
String ToString(const String&) const | Converts the value of the current object to equivalent string representation, using the specified format. |
String ToString(const String&, const SharedPtr<IFormatProvider>&) const | Converts the value of the current object to equivalent string representation, using the specified format and format provider. |
String ToString(const String&, const SharedPtr<Globalization::CultureInfo>&) const | |
String ToString(const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&) const | |
String ToString(const String&, std::nullptr_t) const | |
static bool TryParse(const String&, TimeSpan&) | Converts string to equivalent TimeSpan object and returns result of conversion. |
static bool TryParse(const String&, const SharedPtr<IFormatProvider>&, TimeSpan&) | Converts string to equivalent TimeSpan object using the specified format provider and returns result of conversion. |
static bool TryParse(const String&, const SharedPtr<Globalization::CultureInfo>&, TimeSpan&) | |
static bool TryParse(const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, TimeSpan&) | |
static bool TryParse(const String&, std::nullptr_t, TimeSpan&) | |
static bool TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<IFormatProvider>&, TimeSpan&) | Converts string to equivalent TimeSpan object using the specified formats and format provider, and returns result of conversion. |
static bool TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::CultureInfo>&, TimeSpan&) | |
static bool TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::DateTimeFormatInfo>&, TimeSpan&) | |
static bool TryParseExact(const String&, const ArrayPtr<String>&, std::nullptr_t, TimeSpan&) | |
static bool TryParseExact(const String&, const String&, const SharedPtr<IFormatProvider>&, Globalization::TimeSpanStyles, TimeSpan&) | Converts string to equivalent TimeSpan object using the specified format, format provider and styles, and returns result of conversion. |
static bool TryParseExact(const String&, const String&, const SharedPtr<Globalization::CultureInfo>&, Globalization::TimeSpanStyles, TimeSpan&) | |
static bool TryParseExact(const String&, const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::TimeSpanStyles, TimeSpan&) | |
static bool TryParseExact(const String&, const String&, std::nullptr_t, Globalization::TimeSpanStyles, TimeSpan&) | |
static bool TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<IFormatProvider>&, Globalization::TimeSpanStyles, TimeSpan&) | Converts string to equivalent TimeSpan object using the specified formats, format provider and styles, and returns result of conversion. |
static bool TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::CultureInfo>&, Globalization::TimeSpanStyles, TimeSpan&) | |
static bool TryParseExact(const String&, const ArrayPtr<String>&, const SharedPtr<Globalization::DateTimeFormatInfo>&, Globalization::TimeSpanStyles, TimeSpan&) | |
static bool TryParseExact(const String&, const ArrayPtr<String>&, std::nullptr_t, Globalization::TimeSpanStyles, TimeSpan&) | |
static bool TryParseExact(const String&, const String&, const SharedPtr<IFormatProvider>&, TimeSpan&) | Converts string to equivalent TimeSpan object using the specified format and format provider, and returns result of conversion. |
static bool TryParseExact(const String&, const String&, const SharedPtr<Globalization::CultureInfo>&, TimeSpan&) | |
static bool TryParseExact(const String&, const String&, const SharedPtr<Globalization::DateTimeFormatInfo>&, TimeSpan&) | |
static bool TryParseExact(const String&, const String&, std::nullptr_t, TimeSpan&) | |
static const TypeInfo& Type() | Returns a TypeInfo object that represent TimeSpan structure. |
Fields
Field | Description |
---|---|
static MaxValue | The TimeSpan object that represents the longest possible interval. |
static MinValue | /// The TimeSpan object that represents the shortest possible interval. |
static constexpr TicksPerDay | The number of 100-nanoseconds intervals in a day (24-hour interval). |
static constexpr TicksPerHour | The number of 100-nanoseconds intervals in a hour. |
static constexpr TicksPerMillisecond | The number of 100-nanoseconds intervals in a millisecond. |
static constexpr TicksPerMinute | The number of 100-nanoseconds intervals in a minute. |
static constexpr TicksPerSecond | The number of 100-nanoseconds intervals in a second. |
static Zero | The TimeSpan object that represents zero-interval. |
Remarks
#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
*/
See Also
- Namespace System
- Library Aspose.Slides