This class provides an interface into the system's clock values. In contrast to values of sibling class Ticks, the underlying system timer is not guaranteed to be steady. This means that an object created or set at a later point in time of the program execution, might represent an earlier point in time. This might happen when the system clock gets adjusted in-between two measurements.
Therefore, the class is to be used to represent calendar clock values which usually get converted to human-readable formats (calendar dates and 24/60/60 clock times).
Apart from a few system-dependent conversion methods, the class has no specific interface, but the methods and operators inherited from base TimePointBase.
To construct an object of this type using calendrical date an time values, helper-class CalendarDateTime with its constructor CalendarDateTime(int,int,int,int,int,int,int) is available if module ALib BaseCamp is included in the ALib Distribution. A typical construction with this helper could look like this:
DateTime myDate= CalendarDateTime(2023,1,31,14,5).Get( Timezone::UTC );
Definition at line 40 of file datetime.hpp.
#include <datetime.hpp>
Public Static Method Index: | |
static DateTime | FromEpochSeconds (time_t epochSeconds) |
static ALIB_API DateTime | FromFileTime (const FILETIME &fileTime) |
static ALIB_API DateTime | FromFileTime (const ULARGE_INTEGER &fileTime) |
static ALIB_API DateTime | FromSystemTime (const SYSTEMTIME &systemTime, lang::Timezone timezone=lang::Timezone::Local) |
Public Static Method Index: inherited from TimePointBase< std::chrono::system_clock, DateTime > | |
static DateTime | BeginningOfEpoch () |
static DateTime | EndOfEpoch () |
static DateTime | FromRaw (TRaw raw) |
static DateTime | Now () |
Public Method Index: | |
time_t | InEpochSeconds () const |
bool | operator!= (const DateTime &other) const |
bool | operator< (const DateTime &other) const |
bool | operator<= (const DateTime &other) const |
bool | operator== (const DateTime &other) const |
bool | operator> (const DateTime &other) const |
bool | operator>= (const DateTime &other) const |
ALIB_API FILETIME | ToFileTime () const |
ALIB_API ULARGE_INTEGER | ToFileTimeLI () const |
ALIB_API SYSTEMTIME | ToSystemTime (lang::Timezone timezone=lang::Timezone::Local) const |
Public Method Index: inherited from TimePointBase< std::chrono::system_clock, DateTime > | |
constexpr | TimePointBase (const lang::Initialization init=lang::Initialization::Default) |
constexpr | TimePointBase (TTimePoint internalValue) |
Duration | Age () const |
TTimePoint | Export () const |
void | Import (TTimePoint timePoint) |
bool | IsOlderThan (const Duration &timeSpan) const |
bool | IsSet () |
DateTime | operator+ (const Duration &timeSpan) const |
DateTime | operator+ (const typename Duration::TDuration &timeSpan) const |
DateTime | operator+= (const Duration &timeSpan) |
DateTime | operator+= (const typename Duration::TDuration &timeSpan) |
Duration | operator- (const DateTime &other) const |
DateTime | operator- (const Duration &timeSpan) const |
DateTime | operator- (const typename Duration::TDuration &timeSpan) const |
DateTime | operator-= (const Duration &timeSpan) |
DateTime | operator-= (const typename Duration::TDuration &timeSpan) |
DateTime & | Reset () |
void | SetAs (const DateTime &other) |
void | SetFromRaw (TRaw raw) |
Duration | Since (const DateTime &other) const |
TRaw | ToRaw () const |
void | Unset () |
Additional Inherited Members | |
Public Type Index: inherited from TimePointBase< std::chrono::system_clock, DateTime > | |
using | TRaw |
Integral type used for exporting and importing values in raw units. | |
using | TTimePoint |
The internal c++ type for time points. | |
Protected Field Index: inherited from TimePointBase< std::chrono::system_clock, DateTime > | |
TTimePoint | stamp |
|
inlinestatic |
Static method that creates a DateTime object representing the given system point in time measured in seconds since January 1st 1970, 00:00:00 GMT.
epochSeconds | The milliseconds in the epoch to convert. |
Definition at line 74 of file datetime.hpp.
Static method that creates a DateTime object representing the given "file time". File time is a 64-bit value that represents the number of 100 nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 UTC.
fileTime | The file time to use. |
Static method that creates a DateTime object representing the given "file time". File time is a 64-bit value that represents the number of 100 nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 UTC.
fileTime | The file time to use. |
|
static |
Static method that creates a DateTime object representing the given as windows system time.
systemTime | Pointer to a SYSTEMTIME struct that holds the system time to use. |
timezone | Denote if the time is interpreted as local or UTC. Defaults to TimeZone::Local . |
|
inline |
Converts the internal value into seconds since January 1, 1970, 00:00:00 GMT. The conversion is dependent on time zone and system clock setting of the host.
Definition at line 60 of file datetime.hpp.
|
inline |
Not equal to operator.
other | The time stamp to compare. |
Definition at line 179 of file datetime.hpp.
|
inline |
Less than operator.
other | The time stamp to compare. |
Definition at line 189 of file datetime.hpp.
|
inline |
Less than or equal to operator.
other | The time stamp to compare. |
Definition at line 199 of file datetime.hpp.
|
inline |
Equal to operator.
other | The time stamp to compare. |
Definition at line 168 of file datetime.hpp.
|
inline |
Greater than operator.
other | The time stamp to compare. |
Definition at line 209 of file datetime.hpp.
|
inline |
Greater than or equal to operator.
other | The time stamp to compare. |
Definition at line 219 of file datetime.hpp.
ALIB_API FILETIME ToFileTime | ( | ) | const |
Converts the internal value into windows specific file time, a 64-bit value that represents the number of 100 nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 UTC. The conversion is dependent on time zone and system clock setting of the host.
ALIB_API ULARGE_INTEGER ToFileTimeLI | ( | ) | const |
Converts the internal value into windows specific file time, a 64-bit value that represents the number of 100 nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 UTC. The conversion is dependent on time zone and system clock setting of the host.
ALIB_API SYSTEMTIME ToSystemTime | ( | lang::Timezone | timezone = lang::Timezone::Local | ) | const |
Converts the internal value into windows specific system time struct.
timezone | Denote if the time that is returned should be local or UTC. Defaults to TimeZone::Local . |