struct EE::System::CalendarDate¶
Overview¶
Civil Gregorian calendar date without timezone or timestamp semantics. More…
#include <datetime.hpp> struct CalendarDate { // fields Int32 year { 1970 }; Uint8 month { 1 }; Uint8 day { 1 }; // methods bool isValid() const; int daysInMonth() const; Int64 daysSinceEpoch() const; std::optional<Int64> toUnixTimestamp() const; CalendarDate addDays(Int64 days) const; CalendarDate addMonths(Int64 months) const; CalendarDate addYears(Int64 years) const; auto operator(const CalendarDate&) const; static std::optional<CalendarDate> fromUnixTimestamp(Int64 seconds); static bool isLeapYear(Int32 year); static int daysInMonth(Int32 year, Uint8 month); static CalendarDate today(); };
Detailed Documentation¶
Civil Gregorian calendar date without timezone or timestamp semantics. Arithmetic outside the Int32 year range leaves the value unchanged.
Methods¶
Int64 daysSinceEpoch() const
Signed number of Gregorian days since 1970-01-01; requires a valid date.
std::optional<Int64> toUnixTimestamp() const
Unix seconds at midnight UTC; returns nullopt for an invalid date.
static std::optional<CalendarDate> fromUnixTimestamp(Int64 seconds)
UTC date containing the Unix timestamp, including negative timestamps. Returns nullopt if the date is outside the Int32 year range.