DateTime Class Reference

Represents a point in time. More...

#include <ArmarXCore/core/time/DateTime.h>

Public Member Functions

ClockType clockType () const
 
 DateTime ()
 
 DateTime (const IceUtil::Time &ice)
 
 DateTime (Duration timeSinceEpoch, ClockType clock=ClockType::Virtual, const std::string &hostname="unknown")
 
 DateTime (std::int64_t microSecondsSinceEpoch, ClockType clock=ClockType::Virtual, const std::string &hostname="unknown")
 
std::string hostname () const
 
bool isInvalid () const
 
bool isValid () const
 
 operator IceUtil::Time () const
 
bool operator!= (const DateTime &rhs) const
 
DateTime operator+ (const Duration &rhs) const
 
DateTimeoperator+= (const Duration &rhs)
 
Duration operator- (const DateTime &rhs) const
 
DateTime operator- (const Duration &rhs) const
 
DateTimeoperator-= (const Duration &rhs)
 
bool operator< (const DateTime &rhs) const
 
bool operator<= (const DateTime &rhs) const
 
bool operator== (const DateTime &rhs) const
 
bool operator> (const DateTime &rhs) const
 
bool operator>= (const DateTime &rhs) const
 
std::string toDateString () const
 
std::string toDateTimeString () const
 
Duration toDurationSinceEpoch () const
 
std::int64_t toMicroSeconds () const
 
std::int64_t toMicroSecondsSinceEpoch () const
 
std::int64_t toMilliSecondsSinceEpoch () const
 
std::int64_t toSecondsSinceEpoch () const
 
std::string toString (const std::string &format) const
 String representation of current date time according to given format string. More...
 
std::string toTimeString () const
 

Static Public Member Functions

static DateTime Invalid ()
 
static DateTime microSeconds (long microSeconds)
 
static DateTime Now ()
 
static DateTime now ()
 

Protected Attributes

ClockType _clockType
 
std::string _hostname
 
Duration _timeSinceEpoch
 

Static Protected Attributes

static const Duration _invalidTimeSinceEpoch = Duration::MicroSeconds(std::numeric_limits<long>::min())
 

Detailed Description

Represents a point in time.

API and implementation to match IceUtil::Time (where applicable).

Definition at line 24 of file DateTime.h.

Constructor & Destructor Documentation

◆ DateTime() [1/4]

DateTime ( )

Definition at line 18 of file DateTime.cpp.

+ Here is the caller graph for this function:

◆ DateTime() [2/4]

DateTime ( Duration  timeSinceEpoch,
ClockType  clock = ClockType::Virtual,
const std::string &  hostname = "unknown" 
)

Definition at line 24 of file DateTime.cpp.

◆ DateTime() [3/4]

DateTime ( std::int64_t  microSecondsSinceEpoch,
ClockType  clock = ClockType::Virtual,
const std::string &  hostname = "unknown" 
)

Definition at line 31 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ DateTime() [4/4]

DateTime ( const IceUtil::Time &  ice)

Definition at line 41 of file DateTime.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ clockType()

ClockType clockType ( ) const

Definition at line 123 of file DateTime.cpp.

◆ hostname()

std::string hostname ( ) const

Definition at line 130 of file DateTime.cpp.

◆ Invalid()

DateTime Invalid ( )
static

Definition at line 60 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInvalid()

bool isInvalid ( ) const

Definition at line 140 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid()

bool isValid ( ) const

Definition at line 135 of file DateTime.cpp.

+ Here is the caller graph for this function:

◆ microSeconds()

static DateTime microSeconds ( long  microSeconds)
inlinestatic

Definition at line 91 of file DateTime.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Now()

DateTime Now ( )
static

Definition at line 55 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ now()

static DateTime now ( )
inlinestatic

Definition at line 86 of file DateTime.h.

+ Here is the call graph for this function:

◆ operator IceUtil::Time()

operator IceUtil::Time ( ) const

Definition at line 46 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const DateTime rhs) const

Definition at line 219 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator+()

DateTime operator+ ( const Duration rhs) const

Definition at line 147 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator+=()

DateTime & operator+= ( const Duration rhs)

Definition at line 154 of file DateTime.cpp.

◆ operator-() [1/2]

Duration operator- ( const DateTime rhs) const

Definition at line 177 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator-() [2/2]

DateTime operator- ( const Duration rhs) const

Definition at line 162 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator-=()

DateTime & operator-= ( const Duration rhs)

Definition at line 169 of file DateTime.cpp.

◆ operator<()

bool operator< ( const DateTime rhs) const

Definition at line 184 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator<=()

bool operator<= ( const DateTime rhs) const

Definition at line 191 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const DateTime rhs) const

Definition at line 198 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator>()

bool operator> ( const DateTime rhs) const

Definition at line 205 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ operator>=()

bool operator>= ( const DateTime rhs) const

Definition at line 212 of file DateTime.cpp.

+ Here is the call graph for this function:

◆ toDateString()

std::string toDateString ( ) const

Definition at line 67 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toDateTimeString()

std::string toDateTimeString ( ) const

Definition at line 81 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toDurationSinceEpoch()

Duration toDurationSinceEpoch ( ) const

Definition at line 116 of file DateTime.cpp.

+ Here is the caller graph for this function:

◆ toMicroSeconds()

std::int64_t toMicroSeconds ( ) const
inline

Definition at line 97 of file DateTime.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toMicroSecondsSinceEpoch()

std::int64_t toMicroSecondsSinceEpoch ( ) const

Definition at line 95 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toMilliSecondsSinceEpoch()

std::int64_t toMilliSecondsSinceEpoch ( ) const

Definition at line 102 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toSecondsSinceEpoch()

std::int64_t toSecondsSinceEpoch ( ) const

Definition at line 109 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

std::string toString ( const std::string &  format) const

String representation of current date time according to given format string.

The format is according to https://en.cppreference.com/w/cpp/chrono/c/strftime. For milli seconds and micro seconds, special specifiers "%%msec" and "%%usec" were added respectively.

Example format string for "2022-03-04_16-59-10.981789": "%Y-%m-%d_%H-%M-%S.%%usec".

Parameters
formatFormat string.
Returns
Formatted date time.

Definition at line 88 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toTimeString()

std::string toTimeString ( ) const

Definition at line 74 of file DateTime.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _clockType

ClockType _clockType
protected

Definition at line 132 of file DateTime.h.

◆ _hostname

std::string _hostname
protected

Definition at line 134 of file DateTime.h.

◆ _invalidTimeSinceEpoch

const Duration _invalidTimeSinceEpoch = Duration::MicroSeconds(std::numeric_limits<long>::min())
staticprotected

Definition at line 128 of file DateTime.h.

◆ _timeSinceEpoch

Duration _timeSinceEpoch
protected

Definition at line 130 of file DateTime.h.


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