#include <FXTime.h>
Given that there are 1,000,000 microseconds in a second and roughly 365.24119241192411924119241192412 days in a year, there are roughly 31,556,839,024,390 microseconds in a year. This means that an unsigned 64 bit container can hold the latest date of 20th February, year 584,556 which is probably enough.
FXTime knows when it is in local time and correctly serialises itself such that timezone translation correctly occurs.
Public Member Functions | |
FXTime (FXulong _value=0, bool _isLocalTime=false) | |
FXTime (time_t ctime) | |
FXTime (int ctime) | |
FXTime & | operator= (FXulong _value) |
FXTime & | operator= (time_t ctime) |
FXTime & | operator= (int ctime) |
bool | operator! () const throw () |
bool | operator== (const FXTime &o) const throw () |
bool | operator!= (const FXTime &o) const throw () |
bool | operator< (const FXTime &o) const throw () |
bool | operator> (const FXTime &o) const throw () |
FXTime & | operator+= (const FXTime &b) throw () |
FXTime & | operator+= (FXulong v) throw () |
FXTime & | operator-= (const FXTime &b) throw () |
FXTime & | operator-= (FXulong v) throw () |
time_t | as_time_t () const throw () |
FXTime & | set_time_t (time_t v) throw () |
struct tm * | as_tm (struct tm *buf, bool inLocalTime=false) const |
FXTime & | set_tm (struct tm *buf, bool isInLocalTime=false) |
FXString | asString (const FXString &fmt="%Y/%m/%d %H:%M:%S.%F %Z") const |
FXTime & | toLocalTime () |
FXTime & | toUTC () |
Static Public Member Functions | |
static FXTime | now (bool inLocalTime=false) |
static FXlong | localTimeDiff () |
Public Attributes | |
bool | isLocalTime |
FXulong | value |
Static Public Attributes | |
static const FXulong | micsPerSecond |
static const FXulong | micsPerYear |
static const FXulong | mics1stJan1601 |
static const FXulong | mics1stJan1970 |
Friends | |
FXTime | operator+ (const FXTime &a, const FXTime &b) throw () |
FXTime | operator+ (const FXTime &a, FXulong v) throw () |
FXTime | operator- (const FXTime &a, const FXTime &b) throw () |
FXTime | operator- (const FXTime &a, FXulong v) throw () |
FXAPI FXStream & | operator<< (FXStream &s, const FXTime &i) |
FXAPI FXStream & | operator>> (FXStream &s, FXTime &i) |
FX::FXTime::FXTime | ( | FXulong | _value = 0 , |
|
bool | _isLocalTime = false | |||
) | [inline, explicit] |
Constructs an instance.
FX::FXTime::FXTime | ( | time_t | ctime | ) | [inline, explicit] |
Constructs an instance from a time_t
.
time_t FX::FXTime::as_time_t | ( | ) | const throw () [inline] |
Returns the value as a time_t
.
FXTime& FX::FXTime::set_time_t | ( | time_t | v | ) | throw () [inline] |
Sets the value from a time_t
.
struct tm* FX::FXTime::as_tm | ( | struct tm * | buf, | |
bool | inLocalTime = false | |||
) | const [read] |
Returns the value as a struct
tm
.
FXTime& FX::FXTime::set_tm | ( | struct tm * | buf, | |
bool | isInLocalTime = false | |||
) |
Sets the value from a struct
tm
.
Returns the time as a string of format fmt. The formatting inserts are as for strftime in the C library except that F means microsecond fraction of the form 999999 or 000001 which would mean 0.999999 or 0.000001 of a second
FXTime& FX::FXTime::toLocalTime | ( | ) | [inline] |
Converts time to local time if it isn't already.
FXTime& FX::FXTime::toUTC | ( | ) | [inline] |
Converts time from local time to UTC if it isn't already.
static FXTime FX::FXTime::now | ( | bool | inLocalTime = false |
) | [static] |
Returns this present moment.
static FXlong FX::FXTime::localTimeDiff | ( | ) | [static] |
Returns how much to add or subtract to convert UTC to local time.
const FXulong FX::FXTime::micsPerSecond [static] |
The number of microseconds per second.
const FXulong FX::FXTime::micsPerYear [static] |
The number of microseconds per year.
const FXulong FX::FXTime::mics1stJan1601 [static] |
The number of microseconds that was midnight 1st January 1601 UTC.
const FXulong FX::FXTime::mics1stJan1970 [static] |
The number of microseconds that was midnight 1st January 1970 UTC.
Whether this time is in local time.
FXulong FX::FXTime::value |
The number of elapsed microseconds since midnight 1st January year 0 UTC.