A date/time representation with additional hints for precision, advanced output formatting and support for time zone conversion (using the MamaTimeZone type). More...
#include <MamaDateTime.h>
Public Member Functions | |
MamaDateTime () | |
MamaDateTime (const MamaDateTime ©) | |
MamaDateTime (const char *str, const MamaTimeZone *tz=NULL) | |
Constructor taking a string argument. More... | |
~MamaDateTime () | |
MamaDateTime & | operator= (const MamaDateTime &rhs) |
bool | operator== (const MamaDateTime &rhs) const |
bool | operator!= (const MamaDateTime &rhs) const |
bool | operator< (const MamaDateTime &rhs) const |
bool | operator> (const MamaDateTime &rhs) const |
int | compare (const MamaDateTime &rhs) const |
bool | empty () const |
void | setEpochTime (mama_u32_t secondsSinceEpoch, mama_u32_t microseconds, mamaDateTimePrecision precision=MAMA_DATE_TIME_PREC_UNKNOWN) |
void | setEpochTimeF64 (double secondsSinceEpoch) |
void | setEpochTimeMilliseconds (mama_u64_t millisecondsSinceEpoch) |
void | setEpochTimeMicroseconds (mama_u64_t microsecondsSinceEpoch) |
void | setWithHints (mama_u32_t secondsSinceEpoch, mama_u32_t microseconds, mamaDateTimePrecision precision=MAMA_DATE_TIME_PREC_UNKNOWN, mamaDateTimeHints hints=0) |
void | setPrecision (mamaDateTimePrecision precision) |
void | setFromString (const char *str, const MamaTimeZone *tz=NULL) |
void | setFromString (const char *str, mama_size_t strLen, const MamaTimeZone *tz=NULL) |
void | setToNow () |
void | setToMidnightToday (const MamaTimeZone *tz=NULL) |
void | set (mama_u32_t year, mama_u32_t month, mama_u32_t day, mama_u32_t hour, mama_u32_t minute, mama_u32_t second, mama_u32_t microsecond, mamaDateTimePrecision precision=MAMA_DATE_TIME_PREC_UNKNOWN, const MamaTimeZone *tz=NULL) |
Set the entire date and time for the MamaDateTime. More... | |
void | setTime (mama_u32_t hour, mama_u32_t minute, mama_u32_t second, mama_u32_t microsecond, mamaDateTimePrecision precision=MAMA_DATE_TIME_PREC_UNKNOWN, const MamaTimeZone *tz=NULL) |
Set the time-of-day portion of the MamaDateTime. More... | |
void | setDate (mama_u32_t year, mama_u32_t month, mama_u32_t day) |
Set the date portion of the MamaDateTime. More... | |
void | copyTime (const MamaDateTime ©) |
Copy the time-of-day portion of the MamaDateTime. More... | |
void | copyDate (const MamaDateTime ©) |
Copy the date portion of the MamaDateTime. More... | |
void | clear () |
Clear the entire MamaDateTime. More... | |
void | clearTime () |
Clear the time-of-day portion of the MamaDateTime. More... | |
void | clearDate () |
Clear the date portion of the MamaDateTime. More... | |
void | addSeconds (mama_f64_t seconds) |
void | addSeconds (mama_i32_t seconds) |
void | addMicroseconds (mama_i64_t microSeconds) |
mama_u64_t | getEpochTimeMicroseconds () const |
Get the date and time as microseconds since the Epoch, (using the UTC timezone). More... | |
mama_u64_t | getEpochTimeMicroseconds (const MamaTimeZone &tz) const |
Get the date and time as microseconds since the Epoch in the supplied time zone. More... | |
mama_u64_t | getEpochTimeMilliseconds () const |
mama_u64_t | getEpochTimeMilliseconds (const MamaTimeZone &tz) const |
mama_f64_t | getEpochTimeSeconds () const |
mama_f64_t | getEpochTimeSeconds (const MamaTimeZone &tz) const |
mama_f64_t | getEpochTimeSecondsWithCheck () const |
Get the date and time as seconds since the Epoch, (using the UTC timezone). More... | |
void | getAsString (char *result, mama_size_t maxLen) const |
void | getTimeAsString (char *result, mama_size_t maxLen) const |
void | getDateAsString (char *result, mama_size_t maxLen) const |
const char * | getAsString () const |
Return a string representation of the date/time. More... | |
const char * | getTimeAsString () const |
const char * | getDateAsString () const |
void | getAsFormattedString (char *result, mama_size_t maxLen, const char *format) const |
void | getAsFormattedString (char *result, mama_size_t maxLen, const char *format, const MamaTimeZone &tz) const |
void | getAsStructTimeVal (struct timeval &result) const |
void | getAsStructTimeVal (struct timeval &result, const MamaTimeZone &tz) const |
void | getAsStructTm (struct tm &result) const |
void | getAsStructTm (struct tm &result, const MamaTimeZone &tz) const |
mama_u32_t | getYear () const |
mama_u32_t | getMonth () const |
mama_u32_t | getDay () const |
mama_u32_t | getHour () const |
mama_u32_t | getMinute () const |
mama_u32_t | getSecond () const |
mama_u32_t | getMicrosecond () const |
mamaDayOfWeek | getDayOfWeek () const |
bool | hasTime () const |
Return whether the object has a time component. More... | |
bool | hasDate () const |
Return whether the object has a date component. More... | |
mamaDateTime | getCValue () |
const mamaDateTime | getCValue () const |
A date/time representation with additional hints for precision, advanced output formatting and support for time zone conversion (using the MamaTimeZone type).
Hints include:
The output format strings are similar to that available for the strftime() function with the addition of %; which adds optional (non-zero) fractional second to the string, and %: which adds fractional seconds including trailing zeros, but does not include the ".". The following table provides examples of output.
Actual Time | Output of "%T%;" | Output of "%T%.:" |
---|---|---|
01:23:45 and 678 millisecs | 01:23:45.678 | 01:23:45.678 |
01:23:45 and 0 millisecs | 01:23:45 | 01:23:45.000 |
Wombat::MamaDateTime::MamaDateTime | ( | ) |
Wombat::MamaDateTime::MamaDateTime | ( | const MamaDateTime & | copy) |
|
explicit |
Constructor taking a string argument.
This is the same as calling setFromString() immediately after construction.
Wombat::MamaDateTime::~MamaDateTime | ( | ) |
MamaDateTime& Wombat::MamaDateTime::operator= | ( | const MamaDateTime & | rhs) |
bool Wombat::MamaDateTime::operator== | ( | const MamaDateTime & | rhs) | const |
bool Wombat::MamaDateTime::operator!= | ( | const MamaDateTime & | rhs) | const |
bool Wombat::MamaDateTime::operator< | ( | const MamaDateTime & | rhs) | const |
bool Wombat::MamaDateTime::operator> | ( | const MamaDateTime & | rhs) | const |
int Wombat::MamaDateTime::compare | ( | const MamaDateTime & | rhs) | const |
bool Wombat::MamaDateTime::empty | ( | ) | const |
void Wombat::MamaDateTime::setEpochTime | ( | mama_u32_t | secondsSinceEpoch, |
mama_u32_t | microseconds, | ||
mamaDateTimePrecision | precision = MAMA_DATE_TIME_PREC_UNKNOWN |
||
) |
void Wombat::MamaDateTime::setEpochTimeF64 | ( | double | secondsSinceEpoch) |
void Wombat::MamaDateTime::setEpochTimeMilliseconds | ( | mama_u64_t | millisecondsSinceEpoch) |
void Wombat::MamaDateTime::setEpochTimeMicroseconds | ( | mama_u64_t | microsecondsSinceEpoch) |
void Wombat::MamaDateTime::setWithHints | ( | mama_u32_t | secondsSinceEpoch, |
mama_u32_t | microseconds, | ||
mamaDateTimePrecision | precision = MAMA_DATE_TIME_PREC_UNKNOWN , |
||
mamaDateTimeHints | hints = 0 |
||
) |
void Wombat::MamaDateTime::setPrecision | ( | mamaDateTimePrecision | precision) |
void Wombat::MamaDateTime::setFromString | ( | const char * | str, |
const MamaTimeZone * | tz = NULL |
||
) |
void Wombat::MamaDateTime::setFromString | ( | const char * | str, |
mama_size_t | strLen, | ||
const MamaTimeZone * | tz = NULL |
||
) |
void Wombat::MamaDateTime::setToNow | ( | ) |
void Wombat::MamaDateTime::setToMidnightToday | ( | const MamaTimeZone * | tz = NULL ) |
void Wombat::MamaDateTime::set | ( | mama_u32_t | year, |
mama_u32_t | month, | ||
mama_u32_t | day, | ||
mama_u32_t | hour, | ||
mama_u32_t | minute, | ||
mama_u32_t | second, | ||
mama_u32_t | microsecond, | ||
mamaDateTimePrecision | precision = MAMA_DATE_TIME_PREC_UNKNOWN , |
||
const MamaTimeZone * | tz = NULL |
||
) |
Set the entire date and time for the MamaDateTime.
The year, month and day parameters must all be integers greater than zero.
year | The year (must be 1970 or later). |
month | The month (1 - 12). |
day | The day (1 - 31). |
hour | The hour (0 - 23). |
minute | The minute (0 - 59). |
second | The second (0 - 59). |
microsecond | The second (0 - 999999). |
precision | An explicit precision, if known. |
tz | A timezone to shift from. |
void Wombat::MamaDateTime::setTime | ( | mama_u32_t | hour, |
mama_u32_t | minute, | ||
mama_u32_t | second, | ||
mama_u32_t | microsecond, | ||
mamaDateTimePrecision | precision = MAMA_DATE_TIME_PREC_UNKNOWN , |
||
const MamaTimeZone * | tz = NULL |
||
) |
Set the time-of-day portion of the MamaDateTime.
The date portion is not affected.
hour | The hour (0 - 23). |
minute | The minute (0 - 59). |
second | The second (0 - 59). |
microsecond | The second (0 - 999999). |
precision | An explicit precision, if known. |
tz | A timezone to shift from. |
void Wombat::MamaDateTime::setDate | ( | mama_u32_t | year, |
mama_u32_t | month, | ||
mama_u32_t | day | ||
) |
Set the date portion of the MamaDateTime.
The time-of-day portion is not affected. The year, month and day parameters must all be integers greater than zero.
year | The year (must be 1970 or later). |
month | The month (1 - 12). |
day | The day (1 - 31). |
void Wombat::MamaDateTime::copyTime | ( | const MamaDateTime & | copy) |
Copy the time-of-day portion of the MamaDateTime.
The date portion is not affected.
copy | The object to copy from |
void Wombat::MamaDateTime::copyDate | ( | const MamaDateTime & | copy) |
Copy the date portion of the MamaDateTime.
The time-of-day portion is not affected.
copy | The object to copy from |
void Wombat::MamaDateTime::clear | ( | ) |
Clear the entire MamaDateTime.
void Wombat::MamaDateTime::clearTime | ( | ) |
Clear the time-of-day portion of the MamaDateTime.
The date portion is not affected.
void Wombat::MamaDateTime::clearDate | ( | ) |
Clear the date portion of the MamaDateTime.
The time-of-day portion is not affected.
void Wombat::MamaDateTime::addSeconds | ( | mama_f64_t | seconds) |
void Wombat::MamaDateTime::addSeconds | ( | mama_i32_t | seconds) |
void Wombat::MamaDateTime::addMicroseconds | ( | mama_i64_t | microSeconds) |
mama_u64_t Wombat::MamaDateTime::getEpochTimeMicroseconds | ( | ) | const |
Get the date and time as microseconds since the Epoch, (using the UTC timezone).
mama_u64_t Wombat::MamaDateTime::getEpochTimeMicroseconds | ( | const MamaTimeZone & | tz) | const |
Get the date and time as microseconds since the Epoch in the supplied time zone.
int] | tz The timezone. |
mama_u64_t Wombat::MamaDateTime::getEpochTimeMilliseconds | ( | ) | const |
mama_u64_t Wombat::MamaDateTime::getEpochTimeMilliseconds | ( | const MamaTimeZone & | tz) | const |
mama_f64_t Wombat::MamaDateTime::getEpochTimeSeconds | ( | ) | const |
mama_f64_t Wombat::MamaDateTime::getEpochTimeSeconds | ( | const MamaTimeZone & | tz) | const |
mama_f64_t Wombat::MamaDateTime::getEpochTimeSecondsWithCheck | ( | ) | const |
Get the date and time as seconds since the Epoch, (using the UTC timezone).
If no date value is contained in the dateTime then it will be set to today's date and the calculation made.
void Wombat::MamaDateTime::getAsString | ( | char * | result, |
mama_size_t | maxLen | ||
) | const |
void Wombat::MamaDateTime::getTimeAsString | ( | char * | result, |
mama_size_t | maxLen | ||
) | const |
void Wombat::MamaDateTime::getDateAsString | ( | char * | result, |
mama_size_t | maxLen | ||
) | const |
const char* Wombat::MamaDateTime::getAsString | ( | ) | const |
Return a string representation of the date/time.
Note that the alternative getAsString() methods are more efficient because these method must allocate a temporary buffer (automatically destroyed upon object destruction).
const char* Wombat::MamaDateTime::getTimeAsString | ( | ) | const |
const char* Wombat::MamaDateTime::getDateAsString | ( | ) | const |
void Wombat::MamaDateTime::getAsFormattedString | ( | char * | result, |
mama_size_t | maxLen, | ||
const char * | format | ||
) | const |
void Wombat::MamaDateTime::getAsFormattedString | ( | char * | result, |
mama_size_t | maxLen, | ||
const char * | format, | ||
const MamaTimeZone & | tz | ||
) | const |
void Wombat::MamaDateTime::getAsStructTimeVal | ( | struct timeval & | result) | const |
void Wombat::MamaDateTime::getAsStructTimeVal | ( | struct timeval & | result, |
const MamaTimeZone & | tz | ||
) | const |
void Wombat::MamaDateTime::getAsStructTm | ( | struct tm & | result) | const |
void Wombat::MamaDateTime::getAsStructTm | ( | struct tm & | result, |
const MamaTimeZone & | tz | ||
) | const |
mama_u32_t Wombat::MamaDateTime::getYear | ( | ) | const |
mama_u32_t Wombat::MamaDateTime::getMonth | ( | ) | const |
mama_u32_t Wombat::MamaDateTime::getDay | ( | ) | const |
mama_u32_t Wombat::MamaDateTime::getHour | ( | ) | const |
mama_u32_t Wombat::MamaDateTime::getMinute | ( | ) | const |
mama_u32_t Wombat::MamaDateTime::getSecond | ( | ) | const |
mama_u32_t Wombat::MamaDateTime::getMicrosecond | ( | ) | const |
mamaDayOfWeek Wombat::MamaDateTime::getDayOfWeek | ( | ) | const |
bool Wombat::MamaDateTime::hasTime | ( | ) | const |
Return whether the object has a time component.
bool Wombat::MamaDateTime::hasDate | ( | ) | const |
Return whether the object has a date component.
mamaDateTime Wombat::MamaDateTime::getCValue | ( | ) |
const mamaDateTime Wombat::MamaDateTime::getCValue | ( | ) | const |