DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::TimeSpan Class Reference

Represents a time interval (duration of time or elapsed time) measured as a positive or negative number of ticks. More...

#include <TimeSpan.h>

Inheritance diagram for DotNetDupe::System::TimeSpan:

Public Member Functions

 TimeSpan ()
 Initializes a new instance of TimeSpan to zero duration.
 TimeSpan (int64_t ticks)
 Initializes a new instance of TimeSpan to the specified number of ticks.
int64_t GetTicks () const
 Gets the number of ticks that represent the value of the current TimeSpan structure.
double GetTotalDays () const
 Gets the value of the current TimeSpan expressed in whole and fractional days.
double GetTotalHours () const
 Gets the value of the current TimeSpan expressed in whole and fractional hours.
double GetTotalMilliseconds () const
 Gets the value of the current TimeSpan expressed in whole and fractional milliseconds.
double GetTotalMinutes () const
 Gets the value of the current TimeSpan expressed in whole and fractional minutes.
double GetTotalSeconds () const
 Gets the value of the current TimeSpan expressed in whole and fractional seconds.
bool operator!= (const TimeSpan &other) const
 Indicates whether two TimeSpan instances are not equal.
TimeSpan operator+ (const TimeSpan &other) const
 Adds a specified TimeSpan to this instance.
TimeSpan operator- (const TimeSpan &other) const
 Subtracts a specified TimeSpan from this instance.
bool operator< (const TimeSpan &other) const
 Indicates whether a specified TimeSpan is less than another specified TimeSpan.
bool operator<= (const TimeSpan &other) const
 Indicates whether a specified TimeSpan is less than or equal to another specified TimeSpan.
bool operator== (const TimeSpan &other) const
 Indicates whether two TimeSpan instances are equal.
bool operator> (const TimeSpan &other) const
 Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
bool operator>= (const TimeSpan &other) const
 Indicates whether a specified TimeSpan is greater than or equal to another specified TimeSpan.
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Static Public Member Functions

static TimeSpan FromDays (double value)
 Returns a TimeSpan that represents a specified number of days.
static TimeSpan FromHours (double value)
 Returns a TimeSpan that represents a specified number of hours.
static TimeSpan FromMilliseconds (double value)
 Returns a TimeSpan that represents a specified number of milliseconds.
static TimeSpan FromMinutes (double value)
 Returns a TimeSpan that represents a specified number of minutes.
static TimeSpan FromSeconds (double value)
 Returns a TimeSpan that represents a specified number of seconds.
static TimeSpan FromTicks (int64_t ticks)
 Returns a TimeSpan that represents a specified number of ticks.
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Static Public Attributes

static constexpr int64_t TicksPerDay = TicksPerHour * 24
 The number of ticks in 1 day.
static constexpr int64_t TicksPerHour = TicksPerMinute * 60
 The number of ticks in 1 hour.
static constexpr int64_t TicksPerMillisecond = 10000
 The number of ticks in 1 millisecond.
static constexpr int64_t TicksPerMinute = TicksPerSecond * 60
 The number of ticks in 1 minute.
static constexpr int64_t TicksPerSecond = TicksPerMillisecond * 1000
 The number of ticks in 1 second.

Detailed Description

Represents a time interval (duration of time or elapsed time) measured as a positive or negative number of ticks.

Note
Conforms to ECMA-335 Partition IV Section 5.17 (System.TimeSpan). Each tick represents a 100-nanosecond interval (0.1 microseconds).

Definition at line 20 of file TimeSpan.h.

Constructor & Destructor Documentation

◆ TimeSpan() [1/2]

◆ TimeSpan() [2/2]

DotNetDupe::System::TimeSpan::TimeSpan ( int64_t ticks)
inline

Initializes a new instance of TimeSpan to the specified number of ticks.

Parameters
ticksA time period expressed in 100-nanosecond units.

Definition at line 42 of file TimeSpan.h.

Member Function Documentation

◆ FromDays()

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

Returns a TimeSpan that represents a specified number of days.

Parameters
valueA number of days, accurate to the nearest millisecond.
Returns
An object that represents value.

Definition at line 96 of file TimeSpan.h.

References TimeSpan(), and TicksPerDay.

◆ FromHours()

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

Returns a TimeSpan that represents a specified number of hours.

Parameters
valueA number of hours, accurate to the nearest millisecond.
Returns
An object that represents value.

Definition at line 91 of file TimeSpan.h.

References TimeSpan(), and TicksPerHour.

◆ FromMilliseconds()

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

Returns a TimeSpan that represents a specified number of milliseconds.

Parameters
valueA number of milliseconds, accurate to the nearest millisecond.
Returns
An object that represents value.

Definition at line 76 of file TimeSpan.h.

References TimeSpan(), and TicksPerMillisecond.

◆ FromMinutes()

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

Returns a TimeSpan that represents a specified number of minutes.

Parameters
valueA number of minutes, accurate to the nearest millisecond.
Returns
An object that represents value.

Definition at line 86 of file TimeSpan.h.

References TimeSpan(), and TicksPerMinute.

◆ FromSeconds()

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

Returns a TimeSpan that represents a specified number of seconds.

Parameters
valueA number of seconds, accurate to the nearest millisecond.
Returns
An object that represents value.

Definition at line 81 of file TimeSpan.h.

References TimeSpan(), and TicksPerSecond.

◆ FromTicks()

TimeSpan DotNetDupe::System::TimeSpan::FromTicks ( int64_t ticks)
inlinestatic

Returns a TimeSpan that represents a specified number of ticks.

Parameters
ticksA number of 100-nanosecond ticks.
Returns
An object that represents ticks.

Definition at line 71 of file TimeSpan.h.

References TimeSpan().

◆ GetTicks()

int64_t DotNetDupe::System::TimeSpan::GetTicks ( ) const
inline

Gets the number of ticks that represent the value of the current TimeSpan structure.

Returns
The number of 100-nanosecond ticks.

Definition at line 46 of file TimeSpan.h.

Referenced by DotNetDupe::System::DateTime::Add(), DotNetDupe::System::Diagnostics::Stopwatch::ElapsedTicks(), DotNetDupe::System::TimeZone::IsDaylightSavingTime(), DotNetDupe::System::DateTime::operator+(), and DotNetDupe::System::DateTime::operator-().

◆ GetTotalDays()

double DotNetDupe::System::TimeSpan::GetTotalDays ( ) const
inline

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

Returns
The total number of days represented by this instance.

Definition at line 66 of file TimeSpan.h.

References TicksPerDay.

◆ GetTotalHours()

double DotNetDupe::System::TimeSpan::GetTotalHours ( ) const
inline

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

Returns
The total number of hours represented by this instance.

Definition at line 62 of file TimeSpan.h.

References TicksPerHour.

◆ GetTotalMilliseconds()

double DotNetDupe::System::TimeSpan::GetTotalMilliseconds ( ) const
inline

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

Returns
The total number of milliseconds represented by this instance.

Definition at line 50 of file TimeSpan.h.

References TicksPerMillisecond.

Referenced by DotNetDupe::System::Diagnostics::Stopwatch::ElapsedMilliseconds().

◆ GetTotalMinutes()

double DotNetDupe::System::TimeSpan::GetTotalMinutes ( ) const
inline

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

Returns
The total number of minutes represented by this instance.

Definition at line 58 of file TimeSpan.h.

References TicksPerMinute.

◆ GetTotalSeconds()

double DotNetDupe::System::TimeSpan::GetTotalSeconds ( ) const
inline

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

Returns
The total number of seconds represented by this instance.

Definition at line 54 of file TimeSpan.h.

References TicksPerSecond.

◆ operator!=()

bool DotNetDupe::System::TimeSpan::operator!= ( const TimeSpan & other) const
inline

Indicates whether two TimeSpan instances are not equal.

Definition at line 102 of file TimeSpan.h.

References TimeSpan().

◆ operator+()

TimeSpan DotNetDupe::System::TimeSpan::operator+ ( const TimeSpan & other) const
inline

Adds a specified TimeSpan to this instance.

Definition at line 117 of file TimeSpan.h.

References TimeSpan().

◆ operator-()

TimeSpan DotNetDupe::System::TimeSpan::operator- ( const TimeSpan & other) const
inline

Subtracts a specified TimeSpan from this instance.

Definition at line 120 of file TimeSpan.h.

References TimeSpan().

◆ operator<()

bool DotNetDupe::System::TimeSpan::operator< ( const TimeSpan & other) const
inline

Indicates whether a specified TimeSpan is less than another specified TimeSpan.

Definition at line 105 of file TimeSpan.h.

References TimeSpan().

◆ operator<=()

bool DotNetDupe::System::TimeSpan::operator<= ( const TimeSpan & other) const
inline

Indicates whether a specified TimeSpan is less than or equal to another specified TimeSpan.

Definition at line 108 of file TimeSpan.h.

References TimeSpan().

◆ operator==()

bool DotNetDupe::System::TimeSpan::operator== ( const TimeSpan & other) const
inline

Indicates whether two TimeSpan instances are equal.

Definition at line 99 of file TimeSpan.h.

References TimeSpan().

◆ operator>()

bool DotNetDupe::System::TimeSpan::operator> ( const TimeSpan & other) const
inline

Indicates whether a specified TimeSpan is greater than another specified TimeSpan.

Definition at line 111 of file TimeSpan.h.

References TimeSpan().

◆ operator>=()

bool DotNetDupe::System::TimeSpan::operator>= ( const TimeSpan & other) const
inline

Indicates whether a specified TimeSpan is greater than or equal to another specified TimeSpan.

Definition at line 114 of file TimeSpan.h.

References TimeSpan().

Member Data Documentation

◆ TicksPerDay

int64_t DotNetDupe::System::TimeSpan::TicksPerDay = TicksPerHour * 24
staticconstexpr

The number of ticks in 1 day.

Definition at line 35 of file TimeSpan.h.

Referenced by FromDays(), and GetTotalDays().

◆ TicksPerHour

int64_t DotNetDupe::System::TimeSpan::TicksPerHour = TicksPerMinute * 60
staticconstexpr

The number of ticks in 1 hour.

Definition at line 32 of file TimeSpan.h.

Referenced by FromHours(), and GetTotalHours().

◆ TicksPerMillisecond

int64_t DotNetDupe::System::TimeSpan::TicksPerMillisecond = 10000
staticconstexpr

The number of ticks in 1 millisecond.

Definition at line 23 of file TimeSpan.h.

Referenced by FromMilliseconds(), and GetTotalMilliseconds().

◆ TicksPerMinute

int64_t DotNetDupe::System::TimeSpan::TicksPerMinute = TicksPerSecond * 60
staticconstexpr

The number of ticks in 1 minute.

Definition at line 29 of file TimeSpan.h.

Referenced by FromMinutes(), and GetTotalMinutes().

◆ TicksPerSecond

int64_t DotNetDupe::System::TimeSpan::TicksPerSecond = TicksPerMillisecond * 1000
staticconstexpr

The number of ticks in 1 second.

Definition at line 26 of file TimeSpan.h.

Referenced by FromSeconds(), DotNetDupe::System::TimeProvider::GetElapsedTime(), and GetTotalSeconds().


The documentation for this class was generated from the following file: