ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
DateTime Class Reference

Description:


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 38 of file datetime.hpp.

#include <datetime.hpp>

Inheritance diagram for DateTime:
[legend]
Collaboration diagram for DateTime:
[legend]

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 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 (lang::Initialization init=lang::Initialization::Perform)
 
constexpr TimePointBase (TTimePoint internalValue)
 
Duration Age () const
 
TTimePoint Export () const
 
void Import (TTimePoint timePoint)
 
bool IsOlderThan (Duration timeSpan) const
 
bool IsSet ()
 
DateTime operator+ (const Duration &timeSpan) const
 
DateTime operator+= (const Duration &timeSpan)
 
Duration operator- (const DateTime &other) const
 
DateTime operator- (const Duration &timeSpan) const
 
DateTime operator-= (const Duration &timeSpan)
 
DateTimeReset ()
 
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
 
using TTimePoint
 

Method Details:

◆ FromEpochSeconds()

static DateTime FromEpochSeconds ( time_t epochSeconds)
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.

Parameters
epochSecondsThe milliseconds in the epoch to convert.
Returns
A time stamp object

Definition at line 72 of file datetime.hpp.

◆ FromFileTime() [1/2]

static ALIB_API DateTime FromFileTime ( const FILETIME & fileTime)
static

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.

Note
Microsoft Windows specific.
Parameters
fileTimeThe file time to use.
Returns
A time stamp object

◆ FromFileTime() [2/2]

static ALIB_API DateTime FromFileTime ( const ULARGE_INTEGER & fileTime)
static

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.

Note
Microsoft Windows specific.
Parameters
fileTimeThe file time to use.
Returns
A time stamp object

◆ FromSystemTime()

static ALIB_API DateTime FromSystemTime ( const SYSTEMTIME & systemTime,
lang::Timezone timezone = lang::Timezone::Local )
static

Static method that creates a DateTime object representing the given as windows system time.

Note
Microsoft Windows specific.
Parameters
systemTimePointer to a SYSTEMTIME struct that holds the system time to use.
timezoneDenote if the time is interpreted as local or UTC. Defaults to TimeZone::Local.
Returns
Seconds in the epoch.

◆ InEpochSeconds()

time_t InEpochSeconds ( ) const
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.

Returns
Seconds in the epoch.

Definition at line 58 of file datetime.hpp.

◆ operator!=()

bool operator!= ( const DateTime & other) const
inline

Not equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 177 of file datetime.hpp.

◆ operator<()

bool operator< ( const DateTime & other) const
inline

Less than operator.

Parameters
otherThe time stamp to compare.
Returns
A reference to this object.

Definition at line 187 of file datetime.hpp.

◆ operator<=()

bool operator<= ( const DateTime & other) const
inline

Less than or equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 197 of file datetime.hpp.

◆ operator==()

bool operator== ( const DateTime & other) const
inline

Equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 166 of file datetime.hpp.

◆ operator>()

bool operator> ( const DateTime & other) const
inline

Greater than operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 207 of file datetime.hpp.

◆ operator>=()

bool operator>= ( const DateTime & other) const
inline

Greater than or equal to operator.

Parameters
otherThe time stamp to compare.
Returns
The result of the comparison.

Definition at line 217 of file datetime.hpp.

◆ ToFileTime()

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.

Note
Microsoft Windows specific.
Returns
The Windows OS file time value represented by this object.

◆ ToFileTimeLI()

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.

Note
Microsoft Windows specific.
Returns
The Windows OS file time represented by this object as type struct ULARGE_INTEGER.

◆ ToSystemTime()

ALIB_API SYSTEMTIME ToSystemTime ( lang::Timezone timezone = lang::Timezone::Local) const

Converts the internal value into windows specific system time struct.

Note
Microsoft Windows specific.
Parameters
timezoneDenote if the time that is returned should be local or UTC. Defaults to TimeZone::Local.
Returns
The time point as SYSTEMTIME.

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