ADTF
3.18.3
|
DateTime class representing both Date and Time. More...
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) | |
Constructor for presetting the stored date and time. More... | |
void | set (int year, int month, int day, int hour, int minute, int second, int microsecond=0) |
Set the stored date and time. More... | |
void | set (timestamp_t timestamp, TimestampReference timestampReference=TimestampReference::MicroSecondsSinceJulianDateOrigin) |
Set stored data and time from a timestamp. More... | |
timestamp_t | toTimestamp (TimestampReference timestampReference=TimestampReference::MicroSecondsSinceJulianDateOrigin) const |
Convert stored date and time to a timestamp. More... | |
std::string | format (const std::string &format_str) const |
Format the date/time string. More... | |
bool | set (const std::string &format_str, const std::string &date_time) |
Sets the date time given a string. More... | |
Public Member Functions inherited from Date | |
Date () | |
Default constructor - initializes the date to 00.00.0000. | |
Date (int year, int month, int day) | |
Constructor for presetting the stored date. More... | |
void | set (int year, int month, int day) |
Sets the stored date. More... | |
bool | set (const std::string &date) |
Sets the stored date given a date string. More... | |
void | setDay (int day) |
Sets the day of the month. More... | |
int | getDay () const |
Get the day of the month. More... | |
void | setMonth (int month) |
Set the month. More... | |
int | getMonth () const |
Get the month. More... | |
void | setYear (int year) |
Set the year. More... | |
int | getYear () const |
Get the year. More... | |
std::string | format (const std::string &format_str) const |
Creates a string representation of the stored date. More... | |
Public Member Functions inherited from Time | |
Time () | |
Default constructor - initializes the time to 00:00:00,0. | |
Time (int hour, int minute, int second, int microsecond=0) | |
Constructor for presetting the stored time. More... | |
void | set (int hour, int minute, int second, int microsecond=0) |
Sets the stored time. More... | |
bool | set (const std::string &time) |
Sets the time a given time string. More... | |
void | setHour (int hour) |
Set the hour. More... | |
int | getHour () const |
Get the hour. More... | |
void | setMinute (int minute) |
Set the minute. More... | |
int | getMinute () const |
Get the minute. More... | |
void | setSecond (int second) |
Set the second. More... | |
int | getSecond () const |
Get the second. More... | |
void | setMicrosecond (int microsecond) |
Set the microsecond. More... | |
int | getMicrosecond () const |
Get the microsecond. More... | |
std::string | format (const std::string &format_str) const |
Creates a string representation of the stored time. More... | |
DateTime class representing both Date and Time.
Definition at line 306 of file workspace/conan/dev_essential/1.3.4/dw/stable/package/aef85909f792a5a628750d25016a24323084963f/include/a_util/datetime/datetime.h.
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 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 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 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 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 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.