Date implementation representing a date consisting of year, month and day.
More...
|
| 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...
|
|
|
int | _day |
|
int | _month |
|
int | _year |
|
Date implementation representing a date consisting of year, month and day.
- Warning
- : This class does not enforce date consistency! E.g. "42.102.20000" is a valid date!
Definition at line 29 of file workspace/conan/dev_essential/1.3.4/dw/stable/package/aef85909f792a5a628750d25016a24323084963f/include/a_util/datetime/datetime.h.
◆ Date()
Date |
( |
int |
year, |
|
|
int |
month, |
|
|
int |
day |
|
) |
| |
Constructor for presetting the stored date.
- Parameters
-
[in] | year | The year. |
[in] | month | The month. |
[in] | day | The day of the month. |
◆ format()
std::string format |
( |
const std::string & |
format_str | ) |
const |
Creates a string representation of the stored date.
This format identifiers are supported: a A b B c d H I j m M p S U w W x X y Y Percent signs are escaped by %% %#<character> is not supported because it only makes sense with Z which is also not supported
- Parameters
-
[in] | format_str | The format of the string representation (see DateTime::format, might be empty). |
- Returns
- A string representation of the stored date.
- Exceptions
-
std::invalid_argument | If the format string is invalid |
◆ getDay()
Get the day of the month.
- Returns
- The day of the month.
◆ getMonth()
Get the month.
- Returns
- The month.
◆ getYear()
Get the year.
- Returns
- The year.
◆ set() [1/2]
bool set |
( |
const std::string & |
date | ) |
|
Sets the stored date given a date string.
This string formats are supported: yyyy.mm.dd or dd.mm.yyyy
-
yyyy
Year as decimal number (zero-padded 0000..9999)
-
mm
Month as decimal number (zero-padded 01..12)
-
dd
Day of month as decimal number (zero-padded 01..31)
-
. Separator for year.month.day or day.month.year
- Parameters
-
[in] | date | The string contains the given date as string. |
- Returns
false
if the date string is invalid, true
otherwise
◆ set() [2/2]
void set |
( |
int |
year, |
|
|
int |
month, |
|
|
int |
day |
|
) |
| |
Sets the stored date.
- Parameters
-
[in] | year | The year. |
[in] | month | The month. |
[in] | day | The day of the month. |
◆ setDay()
Sets the day of the month.
- Parameters
-
[in] | day | The day of the month. |
◆ setMonth()
void setMonth |
( |
int |
month | ) |
|
Set the month.
- Parameters
-
◆ setYear()