This class represents a point in time as a set of calendar and clock values (year, month, day, hour, ...). It provides methods to convert to and from objects of type DateTime. In addition, a method to format the date and time into human-readable string value is available.
CalendarDateTime <=> DateTime <=> Ticks
Definition at line 47 of file calendar.hpp.
#include <calendar.hpp>
Public Field Index: | |
int | Day |
The calendar day (1..31). | |
int | DayOfWeek |
int | Hour |
The calendar hour (0..23). | |
int | Millisecond |
The calendar millisecond (0..999). | |
int | Minute |
The calendar minute (0..59). | |
int | Month |
The calendar month (1..12). | |
int | Second |
The calendar second (0..59). | |
int | Year |
The calendar year (e.g., 2022). | |
Public Method Index: | |
CalendarDateTime (const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local) | |
CalendarDateTime (Initialization init=Initialization::Default) | |
CalendarDateTime (int year, int month=1, int day=1, int hour=0, int minute=0, int second=0, int millisecond=0) | |
ALIB_API void | Clear () |
Sets all public values to 0 . | |
ALIB_API AString & | Format (Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const |
ALIB_API DateTime | Get (lang::Timezone timezone=lang::Timezone::Local) const |
ALIB_API void | Set (const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local) |
int Day |
The calendar day (1..31).
Definition at line 57 of file calendar.hpp.
int DayOfWeek |
The calendar day of week (0==Sunday..6==Saturday).
-1
if constructed with single values, or if method Clear is invoked. Definition at line 75 of file calendar.hpp.
int Hour |
The calendar hour (0..23).
Definition at line 60 of file calendar.hpp.
int Millisecond |
The calendar millisecond (0..999).
Definition at line 69 of file calendar.hpp.
int Minute |
The calendar minute (0..59).
Definition at line 63 of file calendar.hpp.
int Month |
The calendar month (1..12).
Definition at line 54 of file calendar.hpp.
int Second |
The calendar second (0..59).
Definition at line 66 of file calendar.hpp.
int Year |
The calendar year (e.g., 2022).
Definition at line 51 of file calendar.hpp.
|
inline |
Constructs an unset object.
init | If Initialization::Default or nulled, Clear is invoked. Otherwise fields are not initialized. Defaults to Initialization::Default . |
Definition at line 82 of file calendar.hpp.
|
inline |
Constructs the object according to the given timestamp object and time zone.
timeStamp | The point in time to use for setting the public fields |
timezone | Denotes if the time that is calculated should be local or UTC. Defaults to TimeZone::Local . |
Definition at line 94 of file calendar.hpp.
|
inline |
Constructs the object according to the given date and time values.
year | The year of the calendar time. |
month | The month of the calendar time. |
day | The day of the calendar time. |
hour | The hour of the calendar time. |
minute | The minute of the calendar time. |
second | The second of the calendar time. |
millisecond | The millisecond of the calendar time. |
Definition at line 109 of file calendar.hpp.
void Clear | ( | ) |
Sets all public values to 0
.
Definition at line 28 of file calendar.cpp.
AString & Format | ( | Substring | format, |
AString & | target, | ||
lang::CurrentData | targetData = lang::CurrentData::Keep ) const |
Formats the date using a given pattern string. Within the pattern string, different symbols are interpreted as tokens. The format is compatible with C# time format strings, as well as with class SimpleDateFormat of the Java APIs.
Strings within the format text that should not be interpreted as tokens may be surrounded by single quotes. Strings within the format text that should not be interpreted as tokens may be given in single quotes. Two consecutive single quotes will be replaced to one single quote.
y | The year with as many digits as it has (for current dates this is 4). |
yy | The year, truncated to 2 digits (modulo 100). |
yyy...y | The year with a minimum amount of digits as amount of y-characters given. |
M | The month as numbers from 1..12. |
MM | The month as numbers from 01..12. |
MMM | The month as abbreviated, 3-digit word defined by resourced strings (defaults to English language). |
MMMM | The month as word defined by resourced strings (defaults to English language). |
d | The day as numbers from 1..31. |
dd | The day as numbers from 01..31. |
ddd | The day as abbreviated, 3-digit word defined by resourced strings (defaults to English language). |
dddd | The day as word defined by resourced strings (defaults to English language). |
H | The hour as numbers from 0..23. |
HH | The hour as numbers from 00..23. |
K | The hour as numbers from 0..11 am/pm. |
KK | The hour as numbers from 00..11 am/pm. |
m | The minute as numbers from 0..59. |
mm | The minute as numbers from 00..59. |
s | The second as numbers from 0..59. |
ss | The second as numbers from 00..59. |
format | The format pattern string. |
target | A reference to an AString that gets the result of the format processing appended. |
targetData | If CurrentData::Keep (the default) the string is appended to target. if CurrentData::Clear , target is cleared. |
Definition at line 1106 of file basecamp.cpp.
DateTime Get | ( | lang::Timezone | timezone = lang::Timezone::Local | ) | 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 . |
Definition at line 82 of file calendar.cpp.
void Set | ( | const DateTime & | timeStamp, |
lang::Timezone | timezone = lang::Timezone::Local ) |
Sets the public fields according to the given timestamp object.
timeStamp | The point in time to use for setting the public fields |
timezone | Denotes if the time that is calculated should be local or UTC. Defaults to TimeZone::Local . |
Definition at line 40 of file calendar.cpp.