Date class.
More...
◆ cDate() [1/3]
Constructor for presetting the stored date.
- Parameters
-
nYear | The year. |
nMonth | The month. |
nDay | The day of the month. |
◆ cDate() [2/3]
Constructor that presets the stored date from a given data structure.
- Parameters
-
psDate | The date structure. |
◆ cDate() [3/3]
Copy constructor.
- Parameters
-
◆ DateDiff() [1/2]
Calculates the difference between two dates.
- Note
- The second date has to be later on first date. Daylight-saving time within the two dates is not supported.
- Parameters
-
[in] | str | The format string of the output. |
The formatting codes are listed below:
-
d
Difference between two dates in days
-
m
Difference between two dates in months
-
y
Difference between two dates in years
-
w
Difference between two dates in weeks
- Parameters
-
[in] | oDate1 | The first date. |
[in] | oDate2 | The second date. |
- Return values
-
ERR_INVALID_ARG | The output format string length is 0 or any unsupported character was found. |
ERR_OUT_OF_RANGE | The first or second date is invalid (see cDate::Valid). |
ERR_NOT_SUPPORTED | First date is later on second date. |
- Returns
- The difference between two dates according to the output format string.
◆ DateDiff() [2/2]
Calculates the difference between two date strings.
- Note
- The second date has to be later on first date. Daylight-saving time within the two dates is not supported.
- Parameters
-
[in] | str | The format string of the output. |
The formatting codes are listed below:
-
d
Difference between two dates in days
-
m
Difference between two dates in months
-
y
Difference between two dates in years
-
w
Difference between two dates in weeks
- Parameters
-
[in] | strDate1 | The string contains the first date as string. |
[in] | strDate2 | The string contains the second date as string. |
- Return values
-
ERR_INVALID_ARG | The output format string length is 0 or any unsupported character was found. |
ERR_OUT_OF_RANGE | The first or second date is invalid (see cDate::Valid). |
ERR_NOT_SUPPORTED | First date is later on second date. |
- Returns
- The difference between two dates according to the output format string.
◆ Format()
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
-
strFormat | The format of the string representation (see cDateTime::Format, can be empty). |
- Returns
- A string representation of the stored date.
◆ Get()
Fills a date structure with the stored values.
- Parameters
-
psDate | The structure to fill. |
- Returns
- void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ GetCurrentDate()
static cDate GetCurrentDate |
( |
| ) |
|
|
static |
Retrieves the current date (hardware clock with respect to timezone).
- Returns
- The current date.
◆ GetCurrentSystemDate()
static cDate GetCurrentSystemDate |
( |
| ) |
|
|
static |
Retrieves the current system date (in UTC format).
- Returns
- The current date.
◆ GetDateFromString()
Converts a given date string into a date and fill the given date.
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
-
[out] | oDate | The date to fill according to the given date string. |
[in] | strDate | The string contains the given date as string. |
- Return values
-
ERR_INVALID_ARG | The date string length is 0 or any unsupported character was found. |
ERR_UNKNOWN_FORMAT | The date string format is invalid (e.g. yy.mm.dd). |
ERR_OUT_OF_RANGE | The date is invalid (see cDate::Valid). |
ERR_NOERROR | |
◆ GetDay()
Get the day of the month.
- Returns
- The day of the month.
-
void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ GetMonth()
Get the month.
- Returns
- The month.
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ GetNumOfDaysInMonth()
static tInt GetNumOfDaysInMonth |
( |
const tInt |
nMonth, |
|
|
const tInt |
nYear |
|
) |
| |
|
static |
Get the number of days of the given month and year (also consider the leap years).
- Parameters
-
[in] | nMonth | The Month. |
[in] | nYear | The Year. |
- Return values
-
ERR_OUT_OF_RANGE | The month or year is invalid (see cDate::Valid). |
- Returns
- The number of days of the given month and year.
◆ GetYear()
Get the year.
- Returns
- The year.
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ IsLeapYear() [1/2]
tBool IsLeapYear |
( |
| ) |
const |
Check whether or not the stored year is a leap year.
- Returns
- Whether or not the stored year is a leap year.
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ IsLeapYear() [2/2]
Check whether or not the specified year is a leap year.
- Parameters
-
- Returns
- Whether or not the specified year is a leap year.
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ operator=()
The cDate assignment (=) operator reinitializes an existing cDate object with new data.
- Parameters
-
oDate | [in] cDate object to be assigned. |
- Returns
- Reference to accessed cDate object.
◆ Set() [1/3]
Sets the stored date.
- Parameters
-
- Returns
- void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ Set() [2/3]
Sets the stored date.
- Parameters
-
- Returns
- void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ Set() [3/3]
Sets the stored date.
- Parameters
-
nYear | The year. |
nMonth | The month. |
nDay | The day of the month. |
- Returns
- void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ SetDay()
Sets the day of the month.
- Parameters
-
nDay | The day of the month. |
- Returns
- void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ SetMonth()
Set the month.
- Parameters
-
- Returns
- Standard Result Code.
-
void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ SetYear()
Set the year.
- Parameters
-
- Returns
- void
- This method is real-time safe.\nSee @ref page_real_time_safe.\n
◆ Valid()
Check whether or not the stored date is valid.
Range table:
-
Year
(0000..9999)
-
Month
(01..12)
-
Day
Jan, Mar, May, Jul, Aug, Oct, Dec (01..31)
-
Day
Apr, Jun, Sep, Nov (01..30)
-
Day
Feb (01..28)
-
Day
Feb leap year (01..29)
- Returns
- Whether or not the specified date is valid.