|
ADTF
|
DateTime class representing both Date and Time. More...
#include <datetime.h>
Inherits a_util::datetime::Date, and a_util::datetime::Time.
Public Member Functions | |
| DateTime () | |
| Default constructor - see Date and Time constructors. | |
| DateTime (int year, int month, int day, int hour, int minute, int second, int microsecond=0) | |
| void | set (int year, int month, int day, int hour, int minute, int second, int microsecond=0) |
| void | set (timestamp_t timestamp, TimestampReference timestampReference=TimestampReference::MicroSecondsSinceJulianDateOrigin) |
| timestamp_t | toTimestamp (TimestampReference timestampReference=TimestampReference::MicroSecondsSinceJulianDateOrigin) const |
| std::string | format (const std::string &format_str) const |
| bool | set (const std::string &format_str, const std::string &date_time) |
Public Member Functions inherited from a_util::datetime::Date | |
| Date () | |
| Default constructor - initializes the date to 00.00.0000. | |
| Date (int year, int month, int day) | |
| void | set (int year, int month, int day) |
| bool | set (const std::string &date) |
| void | setDay (int day) |
| int | getDay () const |
| void | setMonth (int month) |
| int | getMonth () const |
| void | setYear (int year) |
| int | getYear () const |
| std::string | format (const std::string &format_str) const |
Public Member Functions inherited from a_util::datetime::Time | |
| Time () | |
| Default constructor - initializes the time to 00:00:00,0. | |
| Time (int hour, int minute, int second, int microsecond=0) | |
| void | set (int hour, int minute, int second, int microsecond=0) |
| bool | set (const std::string &time) |
| void | setHour (int hour) |
| int | getHour () const |
| void | setMinute (int minute) |
| int | getMinute () const |
| void | setSecond (int second) |
| int | getSecond () const |
| void | setMicrosecond (int microsecond) |
| int | getMicrosecond () const |
| std::string | format (const std::string &format_str) const |
| a_util::datetime::DateTime::DateTime | ( | int | year, |
| int | month, | ||
| int | day, | ||
| int | hour, | ||
| int | minute, | ||
| int | second, | ||
| int | microsecond = 0 ) |
Constructor for presetting the stored date and time.
| [in] | year | The year. |
| [in] | month | The month. |
| [in] | day | The day of the month. |
| [in] | hour | The hour. |
| [in] | minute | The minute. |
| [in] | second | The second. |
| [in] | microsecond | The microsecond. |
| std::string a_util::datetime::DateTime::format | ( | const std::string & | format_str | ) | const |
Format the date/time string.
Returns a formated string containing date/time information. The format argument consists of one or more codes; as in printf(), the formatting codes are preceded by a percent sign ('%'). Characters that do not begin with % are copied unchanged.
The formatting codes are listed below:
%a Abbreviated weekday name %A Full weekday name %b Abbreviated month name %B Full month name %c Date and time representation appropriate for locale %d Day of month as decimal number (01 31) %H Hour in 24-hour format (00 23) %I Hour in 12-hour format (01 12) %j Day of year as decimal number (001 366) %m Month as decimal number (01 12) %M Minute as decimal number (00 59) %p Current locale's A.M./P.M. indicator for 12-hour clock %S Second as decimal number (00 59) %U Week of year as decimal number, with Sunday as first day of week (00 53) %w Weekday as decimal number (0 6; Sunday is 0) %W Week of year as decimal number, with Monday as first day of week (00 53) %x Date representation for current locale %X Time representation for current locale %y Year without century, as decimal number (00 99) %Y Year with century, as decimal number %z,Z Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown %% Percent sign As in the printf() function, the # flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows.
%#a, %#A, %#b, %#B
Characters are converted to uppercase.
For example: "TUESDAY", "MARCH".
| [in] | format_str | Format-control string. |
| std::invalid_argument | If the format string is invalid |
| bool a_util::datetime::DateTime::set | ( | const std::string & | format_str, |
| const std::string & | date_time ) |
Sets the date time given a string
The formatting codes are listed below:
%b Abbreviated month name %B Full month name %m Month as decimal number (space-padded _1..12, zero-padded 01..12, normal 1 -12) %d Day of month as decimal number (space-padded _1..31, zero-padded 01..31, normal 1-31) %y Year without century, as decimal number (00 99) %Y Year with century, as decimal number %H Hour in 24-hour format (00 23) %I Hour in 12-hour format (01 12) %p AM / PM and am / pm detection %M Minute as decimal number (00 59) %S Second as decimal number (00 59) | [in] | format_str | format string (see list) |
| [in] | date_time | string containing the date / time string |
| true | if the conversion is OK, in this case the local data structures are updated with the new values |
| false | Otherwise |
| void a_util::datetime::DateTime::set | ( | int | year, |
| int | month, | ||
| int | day, | ||
| int | hour, | ||
| int | minute, | ||
| int | second, | ||
| int | microsecond = 0 ) |
Set the stored date and time.
| [in] | year | The year. |
| [in] | month | The month. |
| [in] | day | The day of the month. |
| [in] | hour | The hour. |
| [in] | minute | The minute. |
| [in] | second | The second. |
| [in] | microsecond | The microsecond. |
| void a_util::datetime::DateTime::set | ( | timestamp_t | timestamp, |
| TimestampReference | timestampReference = TimestampReference::MicroSecondsSinceJulianDateOrigin ) |
Set stored data and time from a timestamp.
Since the internal data structure uses julian day as the reference point, you have to set the timestampReference parameter to the reference point in time that the timestamp parameter uses.
210866803200000000 to the timestamp| [in] | timestamp | The timestamp in number of microseconds that have elapsed since the reference point defined in the timestampReference parameter. |
| [in] | timestampReference | The reference point in time when the count in microseconds was started. Default is julian day. |
| timestamp_t a_util::datetime::DateTime::toTimestamp | ( | TimestampReference | timestampReference = TimestampReference::MicroSecondsSinceJulianDateOrigin | ) | const |
Convert stored date and time to a timestamp.
Since the internal data structure uses julian day as the reference point, this is the default reference point of the timestamp returned by its member function. You can change the reference point in time by the timestampReference parameter.
210866803200000000 from the result. This is the number of microseconds that have elapsed since the Julian day up to the reference point in time in Unix time.| [in] | timestampReference | The reference point in time the returned timestamp should refer to. |
timestampReference parameter. The default reference point int time is julian day.