Death::Containers::DateTime class

Instant in time, typically expressed as a date and time of day.

Public types

class TimeZone
Represents a timezone that can be used in timezone conversions in DateTime.
struct Tm
Describes a date and time represented by DateTime.
enum Tz { Local, GMT_12, GMT_11, GMT_10, GMT_9, GMT_8, GMT_7, GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1, GMT0, GMT1, GMT2, GMT3, GMT4, GMT5, GMT6, GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13, UTC = GMT0, WET = GMT0, WEST = GMT1, CET = GMT1, CEST = GMT2, EET = GMT2, EEST = GMT3, MSK = GMT3, MSD = GMT4, AST = GMT_4, ADT = GMT_3, EST = GMT_5, EDT = GMT_4, CST = GMT_6, CDT = GMT_5, MST = GMT_7, MDT = GMT_6, PST = GMT_8, PDT = GMT_7, HST = GMT_10, AKST = GMT_9, AKDT = GMT_8, A_WST = GMT8, A_CST = GMT13 + 1, A_EST = GMT10, A_ESST = GMT11, NZST = GMT12, NZDT = GMT13 }
Well-known timezones.

Public static functions

static auto Now() -> DateTime noexcept
Returns DateTime that is set to the current date and time on this computer, expressed as the local time.
static auto UtcNow() -> DateTime noexcept
Returns DateTime that is set to the current date and time on this computer, expressed as the UTC time.
static auto FromUnixMilliseconds(std::int64_t value) -> DateTime constexpr noexcept
Returns DateTime created from number of milliseconds since 00:00, Jan 1 1970 UTC.

Constructors, destructors, conversion operators

DateTime() constexpr noexcept
Creates invalid DateTime structure.
DateTime(NoInitT) explicit noexcept
Creates uninitialized DateTime structure.
DateTime(time_t timet) constexpr noexcept
Creates DateTime structure from standard time_t value.
DateTime(const struct tm& tm) noexcept
Creates DateTime structure from standard tm structure.
DateTime(const Tm& tm) noexcept
Creates DateTime structure from partitioned DateTime.
DateTime(std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour = 0, std::int32_t minute = 0, std::int32_t second = 0, std::int32_t millisec = 0) noexcept
Creates DateTime structure from individual parts.
DateTime(const struct _SYSTEMTIME& st) noexcept
Creates DateTime structure from Windows® SYSTEMTIME structure.
DateTime(const struct _FILETIME& ft) noexcept
Creates DateTime structure from Windows® FILETIME structure.
operator bool() const explicit noexcept

Public functions

auto GetYear(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetMonth(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetDay(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetWeekDay(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetHour(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetMinute(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetSecond(const TimeZone tz = Local) const -> std::int32_t noexcept
auto GetMillisecond(const TimeZone tz = Local) const -> std::int32_t noexcept
auto Set(time_t timet) -> DateTime& constexpr noexcept
Sets DateTime structure to the value corresponding to standard time_t value.
auto Set(const struct tm& tm) -> DateTime& noexcept
Sets DateTime structure to the value corresponding to standard tm structure.
auto Set(const Tm& tm) -> DateTime& noexcept
Sets DateTime structure to the value corresponding to partitioned DateTime.
auto Set(std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour = 0, std::int32_t minute = 0, std::int32_t second = 0, std::int32_t millisec = 0) -> DateTime& noexcept
Sets DateTime structure from individual parts.
auto SetYear(std::int32_t year) -> DateTime& noexcept
auto SetMonth(std::int32_t month) -> DateTime& noexcept
auto SetDay(std::int32_t day) -> DateTime& noexcept
auto SetHour(std::int32_t hour) -> DateTime& noexcept
auto SetMinute(std::int32_t minute) -> DateTime& noexcept
auto SetSecond(std::int32_t second) -> DateTime& noexcept
auto SetMillisecond(std::int32_t millisecond) -> DateTime& noexcept
auto ResetTime() -> DateTime& noexcept
auto IsValid() const -> bool constexpr noexcept
auto Partitioned(TimeZone tz = Local) const -> Tm noexcept
Returns DateTime structure partitioned into individual components.
auto ToUnixMilliseconds() const -> std::int64_t constexpr noexcept
Returns number of milliseconds since 00:00, Jan 1 1970 UTC.
auto GetTicks() const -> time_t constexpr noexcept
Returns number of seconds since 00:00, Jan 1 1970 UTC.
auto ToTimezone(TimeZone tz, bool noDST = false) const -> DateTime noexcept
Creates a new DateTime structure moved from the local timezone to a given timezone.
auto FromTimezone(TimeZone tz, bool noDST = false) const -> DateTime noexcept
Creates a new DateTime structure moved from a given timezone to the local timezone.
void AdjustToTimezone(TimeZone tz, bool noDST = false) noexcept
Moves DateTime structure from the local timezone to a given timezone.
void AdjustFromTimezone(TimeZone tz, bool noDST = false) noexcept
Moves DateTime structure from a given timezone to the local timezone.
auto ToWin32() const -> struct _SYSTEMTIME noexcept
Returns DateTime structure converted to Windows® SYSTEMTIME structure.
auto TryParse(StringView input, StringView format, StringView* endParse = nullptr) -> bool noexcept
auto operator+=(const TimeSpan& ts) -> DateTime& constexpr noexcept
auto operator+(const TimeSpan& ts) const -> DateTime constexpr noexcept
auto operator-=(const TimeSpan& ts) -> DateTime& constexpr noexcept
auto operator-(const TimeSpan& ts) const -> DateTime constexpr noexcept
auto operator-(const DateTime& dt) const -> TimeSpan constexpr noexcept
auto operator<(const DateTime& dt) const -> bool constexpr noexcept
auto operator<=(const DateTime& dt) const -> bool constexpr noexcept
auto operator>(const DateTime& dt) const -> bool constexpr noexcept
auto operator>=(const DateTime& dt) const -> bool constexpr noexcept
auto operator==(const DateTime& dt) const -> bool constexpr noexcept
auto operator!=(const DateTime& dt) const -> bool constexpr noexcept

Enum documentation

enum Death::Containers::DateTime::Tz

Well-known timezones.

Enumerators
Local

Specifies time in the current timezone.

GMT_12

GMT_11

GMT_10

GMT_9

GMT_8

GMT_7

GMT_6

GMT_5

GMT_4

GMT_3

GMT_2

GMT_1

GMT0

GMT1

GMT2

GMT3

GMT4

GMT5

GMT6

GMT7

GMT8

GMT9

GMT10

GMT11

GMT12

GMT13

UTC

WET

WEST

CET

CEST

EET

EEST

MSK

MSD

AST

ADT

EST

EDT

CST

CDT

MST

MDT

PST

PDT

HST

AKST

AKDT

A_WST

A_CST

A_EST

A_ESST

NZST

NZDT

Function documentation

Death::Containers::DateTime::DateTime(std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour = 0, std::int32_t minute = 0, std::int32_t second = 0, std::int32_t millisec = 0) noexcept

Creates DateTime structure from individual parts.

Parameters
year Years
month Months after the year (0-11)
day Days after the month (1-31)
hour Hours after the day (0-23)
minute Minutes after the hour (0-59)
second Seconds after the minute (0-59*)
millisec Milliseconds after the second (0-999)

Death::Containers::DateTime::DateTime(const struct _SYSTEMTIME& st) noexcept

Creates DateTime structure from Windows® SYSTEMTIME structure.

Death::Containers::DateTime::DateTime(const struct _FILETIME& ft) noexcept

Creates DateTime structure from Windows® FILETIME structure.

DateTime& Death::Containers::DateTime::Set(std::int32_t year, std::int32_t month, std::int32_t day, std::int32_t hour = 0, std::int32_t minute = 0, std::int32_t second = 0, std::int32_t millisec = 0) noexcept

Sets DateTime structure from individual parts.

Parameters
year Years
month Months after the year (0-11)
day Days after the month (1-31)
hour Hours after the day (0-23)
minute Minutes after the hour (0-59)
second Seconds after the minute (0-59*)
millisec Milliseconds after the second (0-999)

struct _SYSTEMTIME Death::Containers::DateTime::ToWin32() const noexcept

Returns DateTime structure converted to Windows® SYSTEMTIME structure.