Represents a date in the systems calendar without the provision of a clock time. This class internally uses types DateTime and CalendarDateTime to perform operators +, -, += and -=, but is much more efficient with in- and decrement operators ++ and –. Furthermore it uses only 32-bits of storage.
Besides storing clock-time agnostic date values, the type is useful to securely iterate over dates, because there is no risk of false comparisons due to mixed time-zone and daylight saving properties and in general due to arbitrarily set clock times.
Another small difference is that field DayOfWeek is always kept in a reliable (correct) state, which is not the case with field CalendarDateTime::DayOfWeek.
Internally, the values are stored a 32-bit storage word using the following scheme
0 represents year 1900. This class just stores the year value as is and does not allow negative values. As a result, this class is capable of storing values between 1/1/0000 and 12/31/1,048,576. Definition at line 354 of file calendar.inl.
Public Method Index: | |
| CalendarDate ()=default | |
| Default constructor leaving this object uninitialized (random value). **************. | |
| CalendarDate (CalendarDate &&) noexcept=default | |
| Trivial default move constructor. ***************************************************. | |
| CalendarDate (const CalendarDate &) noexcept=default | |
| Trivial default copy constructor. ***************************************************. | |
| ALIB_DLL | CalendarDate (const CalendarDateTime &calendarDateTime) |
| CalendarDate (const DateTime &dateTime, lang::Timezone timezone) | |
| CalendarDate (int year, int month, int day, int dayOfWeek=-1) | |
| CalendarDate (lang::Timezone timezone) | |
| ~CalendarDate () noexcept=default | |
| Trivial default destructor. ***************************************************. | |
| int | Day () const |
| int | DayOfWeek () const |
| ALIB_DLL DateTime | Get (lang::Timezone timezone=lang::Timezone::Local, int hour=12, int minute=0, int second=0) const |
| int | Month () const |
| bool | operator!= (const CalendarDate &other) const |
| ALIB_DLL CalendarDate | operator+ (int daysToAdd) const |
| ALIB_DLL CalendarDate | operator++ () |
| CalendarDate | operator++ (int) |
| CalendarDate | operator+= (int daysToAdd) |
| CalendarDate | operator- (int daysToSubtract) const |
| ALIB_DLL CalendarDate | operator-- () |
| CalendarDate | operator-- (int) |
| CalendarDate | operator-= (int daysToSubtract) |
| bool | operator< (const CalendarDate &other) const |
| bool | operator<= (const CalendarDate &other) const |
| CalendarDate & | operator= (CalendarDate &&) noexcept=default |
| CalendarDate & | operator= (const CalendarDate &) noexcept=default |
| bool | operator== (const CalendarDate &other) const |
| bool | operator> (const CalendarDate &other) const |
| bool | operator>= (const CalendarDate &other) const |
| ALIB_DLL void | Set (const DateTime &dateTime, lang::Timezone timezone) |
| ALIB_DLL void | Set (int year, int month, int day, int dayOfWeek=-1) |
| ALIB_DLL CalendarDateTime | ToCalendarDateTime () const |
| int | Year () const |
Protected Field Index: | |
| uint32_t | stamp |
| Encoded date value. | |
|
protected |
Encoded date value.
Definition at line 357 of file calendar.inl.
|
inline |
Constructor taking the date as separated values.
| year | The year to use. Must be between 0 and 1,048,575 |
| month | The month to use. Must be between 1 and 12 |
| day | The day to use. Must be between 1 and 31 |
| dayOfWeek | The day of week that results from the previous values. Defaults to -1 which instructs this constructor to retrieve that correct value.If given, values must be between 0 (Sunday) and 6 (Saturday). In debug compilations an assertion will be raised if the value is out of range or inconsistent. |
Definition at line 395 of file calendar.inl.
|
inlineexplicit |
Constructor creating a date that represents "today".
| timezone | Determines whether the local time zone should be used or UTC. |
Definition at line 405 of file calendar.inl.
|
inlineexplicit |
Constructor taking a DateTime value.
| calendarDateTime | The value to take the date from. |
Definition at line 415 of file calendar.inl.
|
inline |
Constructor taking a DateTime value.
| dateTime | The value to take the date from. |
| timezone | Determines whether the local time zone should be used or UTC. |
Definition at line 428 of file calendar.inl.
|
inline |
Extracts the day of month from this date as a value between 1 and 31.
Definition at line 496 of file calendar.inl.
|
inline |
Extracts the day of week from this date as a value between 0 (representing sunday) and 6 (representing Saturday) in accordance with field CalendarDateTime::DayOfWeek.
Definition at line 502 of file calendar.inl.
| DateTime alib::strings::util::CalendarDate::Get | ( | lang::Timezone | timezone = lang::Timezone::Local, |
| int | hour = 12, | ||
| int | minute = 0, | ||
| int | second = 0 ) const |
Creates a DateTime object from this calendar date.
| timezone | Denote if the time that is calculated should be local or UTC. Defaults to TimeZone::Local. |
| hour | The hour of day (0..23) that the value returned should represent. Defaults to noon time (12). |
| minute | The minute of the hour (0..59) that the value returned should represent. Defaults to 0. |
| second | The second of the minute (0..59) that the value returned should represent. Defaults to 0. |
Definition at line 252 of file calendar.cpp.
|
inline |
Extracts the month from this date as a value between 1 and 12.
Definition at line 492 of file calendar.inl.
|
inline |
Not equal to operator.
| other | The date stamp to compare. |
Definition at line 597 of file calendar.inl.
| CalendarDate alib::strings::util::CalendarDate::operator+ | ( | int | daysToAdd | ) | const |
Adds the given number of days to this date.
| daysToAdd | The days to add. May be negative for subtraction. |
Definition at line 257 of file calendar.cpp.
| CalendarDate alib::strings::util::CalendarDate::operator++ | ( | ) |
Prefix increment operator.
Definition at line 265 of file calendar.cpp.
|
inline |
Postfix increment operator.
Definition at line 542 of file calendar.inl.
|
inline |
Adds the given number of days to this date.
| daysToAdd | The days to add. May be negative for subtraction. |
Definition at line 565 of file calendar.inl.
|
inline |
Subtracts the given number of days to this date.
| daysToSubtract | The days to add. May be negative for additions. |
Definition at line 519 of file calendar.inl.
| CalendarDate alib::strings::util::CalendarDate::operator-- | ( | ) |
Prefix decrement operator.
Definition at line 298 of file calendar.cpp.
|
inline |
Postfix decrement operator.
Definition at line 553 of file calendar.inl.
|
inline |
Subtracts the given number of days to this date.
| daysToSubtract | The days to add. May be negative for additons. |
Definition at line 575 of file calendar.inl.
|
inline |
Less than operator.
| other | The date stamp to compare. |
Definition at line 607 of file calendar.inl.
|
inline |
Less than or equal to operator.
| other | The date stamp to compare. |
Definition at line 617 of file calendar.inl.
|
defaultnoexcept |
Trivial default move assign operator.
this. ***************************************************
|
defaultnoexcept |
Trivial default copy assign operator.
this. ***************************************************
|
inline |
Equal to operator.
| other | The date stamp to compare. |
Definition at line 587 of file calendar.inl.
|
inline |
Greater than operator.
| other | The date stamp to compare. |
Definition at line 627 of file calendar.inl.
|
inline |
Greater than or equal to operator.
| other | The date stamp to compare. |
Definition at line 637 of file calendar.inl.
| void alib::strings::util::CalendarDate::Set | ( | const DateTime & | dateTime, |
| lang::Timezone | timezone ) |
Sets this class to the date represented by the given DateTime instance.
| dateTime | The value to take the date from. |
| timezone | Determines whether the local time zone applies to dateTime or whether it refers to UTC. |
Definition at line 215 of file calendar.cpp.
| void alib::strings::util::CalendarDate::Set | ( | int | year, |
| int | month, | ||
| int | day, | ||
| int | dayOfWeek = -1 ) |
Sets this class to the given values.
| year | The year to use. Must be between 0 and 1,048,575 |
| month | The month to use. Must be between 1 and 12 |
| day | The day to use. Must be between 1 and 31 |
| dayOfWeek | The day of week that results from the previous values. Defaults to -1 which instructs this constructor to retrieve that correct value.If given, values must be between 0 (Sunday) and 6 (Saturday). In debug compilations an assertion will be raised if the value is out of range or inconsistent. |
Definition at line 223 of file calendar.cpp.
| ALIB_DLL CalendarDateTime alib::strings::util::CalendarDate::ToCalendarDateTime | ( | ) | const |
Returns a date and time value, by adding 12 o'clock noon time.
|
inline |
Extracts the day of month from this date as a value between 1 and 31.
Definition at line 488 of file calendar.inl.