C++ UTC Time Library
A class to hold UTC times, and associated functionality.
|
#include <utctime.h>
Public Member Functions | |
UTCTime () | |
Default constructor. | |
UTCTime (const std::tm &utc_tm) | |
Constructor taking a std::tm struct. | |
UTCTime (const int year, const int month, const int day, const int hour, const int minute, const int second) | |
Constructor taking individual date values. | |
std::tm | get_tm () const |
Returns a std::tm struct containing the UTC datetime. | |
std::string | time_string () const |
Returns a std::string containing the UTC datetime. | |
std::string | time_string_inet () const |
Returns a std::string containing the UTC datetime in RFC3339 format. | |
time_t | timestamp () const |
Returns a time_t timestamp for the UTC datetime. | |
bool | operator< (const UTCTime &rhs) const |
Overloaded less than operator. | |
bool | operator>= (const UTCTime &rhs) const |
Overloaded greater than or equal to operator. | |
bool | operator> (const UTCTime &rhs) const |
Overloaded greater than operator. | |
bool | operator<= (const UTCTime &rhs) const |
Overloaded less than or equal to operator. | |
bool | operator== (const UTCTime &rhs) const |
Overloaded equality operator. | |
bool | operator!= (const UTCTime &rhs) const |
Overloaded inequality operator. | |
double | operator- (const UTCTime &rhs) const |
Overloaded subtraction operator. |
A class for holding a UTC time.
|
explicit |
Default constructor, which initializes to the current time.
bad_time_init | if unable to get the current time. |
|
explicit |
Constructor taking a std::tm struct.
utc_tm | A std::tm struct containing the desired initialization time. |
bad_time_init | if unable to get the current time. |
invalid_date | if the supplied date is bad. |
|
explicit |
Constructor taking individual date values.
year | The year |
month | The month, 1 to 12 |
day | The day, 1 to 31, depending on month |
hour | The hour, 0 to 23 |
minute | The minute, 0 to 59 |
second | The second, 0 to 59. Leap seconds are not supported. |
bad_time_init | if unable to get the current time. |
invalid_date | if the supplied date is bad. |
std::tm UTCTime::get_tm | ( | ) | const |
Returns a std::tm struct containing the UTC datetime.
bool UTCTime::operator!= | ( | const UTCTime & | rhs | ) | const |
Overloaded inequality operator
rhs | The UTCTime instance to which to compare |
rhs
, false otherwise. double UTCTime::operator- | ( | const UTCTime & | rhs | ) | const |
Overloaded subtraction operator
rhs | The UTCTime instance to subtract from the instance |
bool UTCTime::operator< | ( | const UTCTime & | rhs | ) | const |
Overloaded less than operator
rhs | The UTCTime instance to which to compare |
rhs
, false otherwise. bool UTCTime::operator<= | ( | const UTCTime & | rhs | ) | const |
Overloaded less than or equal to operator
rhs | The UTCTime instance to which to compare |
rhs
, false otherwise. bool UTCTime::operator== | ( | const UTCTime & | rhs | ) | const |
Overloaded equality operator
rhs | The UTCTime instance to which to compare |
rhs
, false otherwise. bool UTCTime::operator> | ( | const UTCTime & | rhs | ) | const |
Overloaded greater than operator
rhs | The UTCTime instance to which to compare |
rhs
, false otherwise. bool UTCTime::operator>= | ( | const UTCTime & | rhs | ) | const |
Overloaded greater than or equal to operator
rhs | The UTCTime instance to which to compare |
rhs
, false otherwise. std::string UTCTime::time_string | ( | ) | const |
Returns a std::string containing the UTC datetime.
bad_time | if unable to get the time. |
std::string UTCTime::time_string_inet | ( | ) | const |
Returns a std::string containing the UTC datetime in RFC3339 format.
bad_time | if unable to get the time. |
time_t UTCTime::timestamp | ( | ) | const |
Returns a time_t timestamp for the UTC datetime.