|
DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
|
An abstraction that provides time-related functions to enable testability of time-dependent code. More...
#include <TimeProvider.h>
Public Member Functions | |
| virtual | ~TimeProvider ()=default |
| Virtual destructor for polymorphic cleanup. | |
| TimeSpan | GetElapsedTime (int64_t startingTimestamp) const |
| Gets the elapsed time since the startingTimestamp was recorded. | |
| TimeSpan | GetElapsedTime (int64_t startingTimestamp, int64_t endingTimestamp) const |
| Gets the elapsed time between two timestamp values. | |
| virtual DateTimeOffset | GetLocalNow () const =0 |
| Gets a DateTimeOffset value that is set to the current date and time in the local time zone. | |
| virtual int64_t | GetTimestamp () const =0 |
| Gets the current high-frequency counter value in ticks. | |
| virtual int64_t | GetTimestampFrequency () const =0 |
| Gets the frequency of the high-frequency counter in ticks per second. | |
| virtual DateTimeOffset | GetUtcNow () const =0 |
| Gets a DateTimeOffset value that is set to the current Coordinated Universal Time (UTC) date and time. | |
| 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 TimeProviderPtr | GetSystem () |
| Gets a TimeProvider that provides the system's current time and high-resolution timer. | |
| 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. | |
An abstraction that provides time-related functions to enable testability of time-dependent code.
Modeled after .NET 8 System.TimeProvider. Provides mockable access to high-resolution timestamps, UTC now, local now, and elapsed duration calculations.
Definition at line 30 of file TimeProvider.h.
|
virtualdefault |
Virtual destructor for polymorphic cleanup.
| TimeSpan DotNetDupe::System::TimeProvider::GetElapsedTime | ( | int64_t | startingTimestamp | ) | const |
Gets the elapsed time since the startingTimestamp was recorded.
| startingTimestamp | The timestamp obtained from a previous call to GetTimestamp. |
Compute elapsed time from starting timestamp to current timestamp.
Definition at line 73 of file TimeProvider.cpp.
References GetElapsedTime(), and GetTimestamp().
Referenced by GetElapsedTime(), and GetTimestampFrequency().
| TimeSpan DotNetDupe::System::TimeProvider::GetElapsedTime | ( | int64_t | startingTimestamp, |
| int64_t | endingTimestamp ) const |
Gets the elapsed time between two timestamp values.
| startingTimestamp | The initial timestamp value. |
| endingTimestamp | The final timestamp value. |
Compute elapsed TimeSpan based on timestamp frequency ticks per second.
Definition at line 78 of file TimeProvider.cpp.
References DotNetDupe::System::TimeSpan::TimeSpan(), GetTimestampFrequency(), and DotNetDupe::System::TimeSpan::TicksPerSecond.
|
pure virtual |
Gets a DateTimeOffset value that is set to the current date and time in the local time zone.
References DOTNETDUPE_API.
Referenced by DotNetDupe::System::DateTimeOffset::Now().
|
static |
Gets a TimeProvider that provides the system's current time and high-resolution timer.
Retrieve singleton shared instance of system TimeProvider.
Definition at line 84 of file TimeProvider.cpp.
References DotNetDupe::System::DynamicCast(), and DotNetDupe::System::SmartPointer< T >::NewShared().
Referenced by GetTimestampFrequency(), DotNetDupe::System::DateTimeOffset::Now(), and DotNetDupe::System::DateTimeOffset::UtcNow().
|
pure virtual |
Gets the current high-frequency counter value in ticks.
References DOTNETDUPE_API.
Referenced by GetElapsedTime(), and DotNetDupe::System::Diagnostics::Stopwatch::Restart().
|
pure virtual |
Gets the frequency of the high-frequency counter in ticks per second.
References DOTNETDUPE_API, GetElapsedTime(), and GetSystem().
Referenced by GetElapsedTime().
|
pure virtual |
Gets a DateTimeOffset value that is set to the current Coordinated Universal Time (UTC) date and time.
References DOTNETDUPE_API.
Referenced by DotNetDupe::System::DateTimeOffset::UtcNow().