Original version by Lulin Song had a similar interface but did not incorporate the standard C library structure, tm.
This class has only one-second accuracy. If you want arithmetic operations and subsecond accuracy, then use Time and TimeInterval.
Public Member Functions | |
CalendarDate (const Time &) | |
Convert from Time. | |
CalendarDate (const std::string &, int offset=-1) | |
Convert from a string. | |
CalendarDate (const std::string &, const std::string &) | |
Facilitate output from hires algorithms (in UTC). | |
CalendarDate (int, unsigned short, unsigned short, unsigned short, unsigned short, unsigned short) | |
Make a CalendarDate from a list of integers (wrt UTC). | |
~CalendarDate () | |
Reproduce responsibly. | |
operator Time () const | |
Autoconversion to Time. | |
Time | getTime () const |
Return a Time. | |
bool | operator== (const CalendarDate &) const |
Equality comparison operator. | |
bool | operator< (const CalendarDate &) const |
Less-than comparison operator. | |
int | getYear () const |
Return the (UTC) year. | |
int | getMonth () const |
Return the (UTC) month (1--12) of the year. | |
int | getDay () const |
Return the (UTC) day (1--31) of the month. | |
int | getHour () const |
Return the (UTC) hour (0--23) of the day. | |
int | getMinute () const |
Return the minute (0--59) of the hour. | |
int | getSecond () const |
Return the second (0--61) of the minute. | |
std::string | getString (bool withSpace=true) const |
Convert a CalendarDate object to a UTC std::string. | |
std::string | getStringForFileName () const |
Convert a CalendarDate object to a UTC std::string that is suitable to use as a file name. | |
bool | isValid (Time *=0) const |
Indicate whether the object represents a valid date. | |
Static Public Member Functions | |
static CalendarDate | UTC (tm &) |
Convert from tm that refers to UTC. | |
static CalendarDate | LocalTime (tm &) |
Convert from tm that refers to local time. | |
static CalendarDate | fromStringForFileName (const std::string &) |
Understands the filename format used by the getStringForFileName function and converts back to a CalendarDate. |
code::CalendarDate::CalendarDate | ( | const std::string & | , | |
int | offset = -1 | |||
) |
Convert from a string.
string | 22 characters formatted as [2001-02/28-16:00:00-UTC] or [2001 02/28 16:00:00 UTC] |
code::CalendarDate::CalendarDate | ( | const std::string & | , | |
const std::string & | ||||
) |
Facilitate output from hires algorithms (in UTC).
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! We assume a TWO-CHARACTER year. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
const_string& | eight characters formatted as ' mmddyy' | |
const_string& | eight characters formatted as ' hhmmss' |
code::CalendarDate::CalendarDate | ( | int | , | |
unsigned | short, | |||
unsigned | short, | |||
unsigned | short, | |||
unsigned | short, | |||
unsigned | short | |||
) |
Make a CalendarDate from a list of integers (wrt UTC).
int | year of "common era" | |
unsigned_short | month (1--12) of the year | |
unsigned_short | day (1--31) of the month | |
unsigned_short | hour (0--23) of the day | |
unsigned_short | minute (0--59) of the hour | |
unsigned_short | second (0--61) of the minute. Values beyond 59 allow for leap seconds. |
code::CalendarDate::~CalendarDate | ( | ) | [inline] |
Reproduce responsibly.
static CalendarDate code::CalendarDate::fromStringForFileName | ( | const std::string & | ) | [static] |
Understands the filename format used by the getStringForFileName function and converts back to a CalendarDate.
The input should look like: 20010228-160316
int code::CalendarDate::getDay | ( | ) | const [inline] |
Return the (UTC) day (1--31) of the month.
int code::CalendarDate::getHour | ( | ) | const [inline] |
Return the (UTC) hour (0--23) of the day.
int code::CalendarDate::getMinute | ( | ) | const [inline] |
Return the minute (0--59) of the hour.
int code::CalendarDate::getMonth | ( | ) | const [inline] |
Return the (UTC) month (1--12) of the year.
int code::CalendarDate::getSecond | ( | ) | const [inline] |
Return the second (0--61) of the minute.
std::string code::CalendarDate::getString | ( | bool | withSpace = true |
) | const |
Convert a CalendarDate object to a UTC std::string.
withSpace,: | if it is true, the returned string looks like [2001 02/28 16:00:00 UTC] with space, otherwise it looks like 20010228-160000 without space which is prefered by XML file or for file name. |
std::string code::CalendarDate::getStringForFileName | ( | ) | const |
Convert a CalendarDate object to a UTC std::string that is suitable to use as a file name.
The result looks like: 20010228-160316
int code::CalendarDate::getYear | ( | ) | const [inline] |
Return the (UTC) year.
bool code::CalendarDate::isValid | ( | Time * | = 0 |
) | const |
Indicate whether the object represents a valid date.
Time* | if nonzero used to store the corresponding Time |
static CalendarDate code::CalendarDate::LocalTime | ( | tm & | ) | [static] |
Convert from tm that refers to local time.
bool code::CalendarDate::operator< | ( | const CalendarDate & | ) | const |
Less-than comparison operator.
bool code::CalendarDate::operator== | ( | const CalendarDate & | ) | const |
Equality comparison operator.
static CalendarDate code::CalendarDate::UTC | ( | tm & | ) | [static] |
Convert from tm that refers to UTC.