Base Framework
|
#include <base/Date.h>
Classes | |
class | DateTime |
Public Types | |
enum | Constants { SUNDAY = 0, MONDAY = 1, TUESDAY = 2, WEDNESDAY = 3, THURSDAY = 4, FRIDAY = 5, SATURDAY = 6, JANUARY = 0, FEBRUARY = 1, MARCH = 2, APRIL = 3, MAY = 4, JUNE = 5, JULY = 6, AUGUST = 7, SEPTEMBER = 8, OCTOBER = 9, NOVEMBER = 10, DECEMBER = 11, EPOCH_YEAR = 1970, EPOCH_WEEKDAY = THURSDAY, DAYS_PER_NONLEAP_YEAR = 365, DAYS_PER_LEAP_YEAR = DAYS_PER_NONLEAP_YEAR + 1, DAYS_PER_400_YEARS = (300+4-1)*365 + (100-4+1)*366, DAYS_PER_WEEK = 7, MONTHS_PER_YEAR = 12, HOURS_PER_DAY = 24, MINUTES_PER_HOUR = 60, MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY, SECONDS_PER_MINUTE = 60, SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR, SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY } |
Public Member Functions | |
Date () noexcept | |
Date (int64 _date) noexcept | |
Date (const Date ©) noexcept | |
Date & | operator= (const Date &assign) noexcept |
int64 | getValue () const noexcept |
operator int64 () const noexcept | |
operator bool () const noexcept | |
Date | getLocalTime () const noexcept |
Date | getUTCTime () const noexcept |
void | addBias (int64 bias) noexcept |
int | getMillisecond () const noexcept |
int | getSecond () const noexcept |
int | getMinute () const noexcept |
int | getHour () const noexcept |
int | getDay () const noexcept |
int | getDayOfWeek () const noexcept |
int | getDayOfYear () const noexcept |
int | getMonth () const noexcept |
int | getYear () const noexcept |
int | getJulianDay () const noexcept |
DateTime | split (bool local=false) const noexcept |
String | getISO8601 (int offset=0) const |
String | getISO8601Compact (int offset=0) const |
String | getISO8601_MS () const |
String | getISO8601_US () const |
String | format (const String &format) const |
WideString | format (const WideString &format) const |
Static Public Member Functions | |
static int | getWeek (const DateTime &dt) noexcept |
static int | normalize (DateTime &dateTime) noexcept |
static bool | isLeapYear (int year) noexcept |
static int | getDaysOfYear (int year) noexcept |
static int | getDaysOfMonth (int month, int year) |
static Date | getNow () |
static int64 | getBias () |
static Date | getTime (int second, int minute, int hour) |
static Date | getDate (int day, int month, int year) |
static Date | getDate (int second, int minute, int hour, int day, int month, int year) |
static Date | getDateByJulianDay (int day) noexcept |
static bool | isValidDateTime (const DateTime &dt) |
static Date | makeDate (const DateTime &dateTime, bool local=false) |
static Date | parseISO8601 (const String &text, bool subsecond=false) |
Static Public Attributes | |
static const int | DAYS_PER_MONTH_NONLEAP_YEAR [MONTHS_PER_YEAR] |
static const int | DAYS_PER_MONTH_LEAP_YEAR [MONTHS_PER_YEAR] |
static const int | DAYS_BEFORE_FIRST_OF_MONTH_NONLEAP_YEAR [MONTHS_PER_YEAR+1] |
static const int | DAYS_BEFORE_FIRST_OF_MONTH_LEAP_YEAR [MONTHS_PER_YEAR+1] |
Date and time.
Representation of date/time in Coordinated Universal Time (UTC). It is recommended that you keep the date/time in UTC and only convert to local time when needed.
enum Date::Constants |
|
inlinenoexcept |
Initializes the date as 00:00:00 on January 1, 1970.
|
inlinenoexcept |
Initializes the date with the specified date.
date | The number of microseconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC). |
|
inlinenoexcept |
Initialize date from other date.
|
inlinenoexcept |
Adds a bias (in microseconds) to the date.
Returns the date/time as a string.
format | The desired format of the resulting string. |
WideString Date::format | ( | const WideString & | format | ) | const |
Returns the date/time as a string.
format | The desired format of the resulting string. |
|
static |
Returns the bias (in microseconds) for convertion from UTC to local time. Bias may change during the lifetime of the process. This method only works on some planet called Earth :-]. UTC = local time + bias.
|
static |
Returns date object for the specified date. Invalid values will be normalized. Raises 'DateException' if the date cannot be represented.
day | The day of the month. |
month | The month of the year. |
year | The year. |
|
static |
Returns date object for the specified date and time. Invalid values will be normalized. Raises 'DateException' if the date cannot be represented.
second | The second. |
minute | The minute. |
hour | The hour. |
day | The day of the month. |
month | The month of the year. |
year | The year. |
|
staticnoexcept |
Returns the date corresponding to the specified Julian day.
|
noexcept |
Returns the day of the month in local time. [1-31].
|
noexcept |
Returns the day of the week in local time. Week starts at Sunday (0).
|
noexcept |
Returns the day of the year in local time.
|
static |
Returns the number of days in the specified month.
|
inlinestaticnoexcept |
Returns the number of days in the specified year.
|
noexcept |
Returns the hour in local time.
String Date::getISO8601 | ( | int | offset = 0 | ) | const |
Returns date/time in ISO 8601 format. E.g. 2020-01-31T18:00:00Z. Offset is in minutes. Date should be in UTC when using offset.
String Date::getISO8601_MS | ( | ) | const |
Returns date/time in ISO 8601 format with milliseconds. E.g. 2020-01-31T18:00:00.123Z.
String Date::getISO8601_US | ( | ) | const |
Returns date/time in ISO 8601 format with microseconds. E.g. 2020-01-31T18:00:00.123456Z.
String Date::getISO8601Compact | ( | int | offset = 0 | ) | const |
Returns date/time in ISO 8601 format. E.g. 20200131T180000Z. Offset is in minutes. Date should be in UTC when using offset.
|
noexcept |
Returns the Julian day.
|
inlinenoexcept |
Converts from UTC to local time.
|
noexcept |
Returns the millisecond in local time.
|
noexcept |
Returns the minute in local time.
|
noexcept |
Returns the month in local time. 0-11.
|
static |
Returns the current time in UTC time.
|
noexcept |
Returns the second in local time.
|
static |
Returns date object for the specified time. Invalid values will be normalized. Raises 'DateException' if the date cannot be represented. The used date is EPOCH.
second | The second. |
minute | The minute. |
hour | The hour. |
|
inlinenoexcept |
Converts from local to UTC time.
|
inlinenoexcept |
Returns the number of microseconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
|
staticnoexcept |
Returns the week of the year.
|
noexcept |
Returns the year in local time.
|
inlinestaticnoexcept |
Returns true if the year is a leap year.
|
static |
Returns true if the date/time is within the valid range.
Returns the date/time for the given date/time components.
dateTime | The broken out date and time. |
local | Specifies that datetime is in local time. UTC by default. |
|
staticnoexcept |
Normalizes the specified data/time structure such that the fields are brought into their normal operating range.
dateTime | The structure to normalize. |
|
inlinenoexcept |
Returns true if date is not epoch.
|
inlinenoexcept |
Returns the number of microseconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
Returns date/time in ISO 8601 format. E.g. 2020-01-31T18:00:00Z.
|
noexcept |
Fills the given time structure with the year, month, day of month, day of week, hour, minute, second, and millisecond (if supported).
time | The time structure. |
local | Specifies that time should be converted to local time from UTC. |
|
static |
The days before the first of the month for leap years.
|
static |
The days before the first of the month for non-leap years.
|
static |
The days per month for leap years.
|
static |
The days per month for non-leap years.