ADTF  3.18.3
Date

Date implementation representing a date consisting of year, month and day. More...

Inheritance diagram for Date:
[legend]

Public Member Functions

 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...
 

Private Attributes

int _day
 
int _month
 
int _year
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Date()

Date ( int  year,
int  month,
int  day 
)

Constructor for presetting the stored date.

Parameters
[in]yearThe year.
[in]monthThe month.
[in]dayThe day of the month.

Member Function Documentation

◆ 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_strThe format of the string representation (see DateTime::format, might be empty).
Returns
A string representation of the stored date.
Exceptions
std::invalid_argumentIf the format string is invalid

◆ getDay()

int getDay ( ) const

Get the day of the month.

Returns
The day of the month.

◆ getMonth()

int getMonth ( ) const

Get the month.

Returns
The month.

◆ getYear()

int getYear ( ) const

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]dateThe 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]yearThe year.
[in]monthThe month.
[in]dayThe day of the month.

◆ setDay()

void setDay ( int  day)

Sets the day of the month.

Parameters
[in]dayThe day of the month.

◆ setMonth()

void setMonth ( int  month)

Set the month.

Parameters
[in]monthThe month.

◆ setYear()

void setYear ( int  year)

Set the year.

Parameters
[in]yearThe year.