struct EE::System::LocalDateTime¶
Overview¶
A local civil date and wall-clock time. More…
#include <datetime.hpp> struct LocalDateTime { // fields CalendarDate date; TimeOfDay time; // methods bool isValid() const; std::optional<Int64> toUnixTimestamp(Int32 utcOffsetSeconds = 0) const; std::optional<Int64> toUnixTimestampMilliseconds(Int32 utcOffsetSeconds = 0) const; LocalDateTime addHours(Int64 hours) const; LocalDateTime addMinutes(Int64 minutes) const; LocalDateTime addSeconds(Int64 seconds) const; auto operator(const LocalDateTime&) const; static std::optional<LocalDateTime> fromUnixTimestamp(Int64 seconds, Int32 utcOffsetSeconds = 0); static std::optional<LocalDateTime> fromUnixTimestampMilliseconds(Int64 milliseconds, Int32 utcOffsetSeconds = 0); static LocalDateTime now(); };
Detailed Documentation¶
A local civil date and wall-clock time. This value does not imply a timezone.
Methods¶
std::optional<Int64> toUnixTimestamp(Int32 utcOffsetSeconds = 0) const
Unix seconds using a UTC offset in seconds (local = UTC + offset), defaulting to UTC. Discards milliseconds; returns nullopt for an invalid value. Does not infer the system timezone or resolve daylight-saving transitions.
std::optional<Int64> toUnixTimestampMilliseconds(Int32 utcOffsetSeconds = 0) const
Unix milliseconds preserving the millisecond field, with the same offset convention. Returns nullopt for an invalid value or an Int64 timestamp overflow.
static std::optional<LocalDateTime> fromUnixTimestamp(Int64 seconds, Int32 utcOffsetSeconds = 0)
Civil date/time at the given UTC offset (default: UTC), with zero milliseconds. Returns nullopt if the result is outside the Int32 year range.
static std::optional<LocalDateTime> fromUnixTimestampMilliseconds(Int64 milliseconds, Int32 utcOffsetSeconds = 0)
Civil date/time at the given UTC offset (default: UTC), preserving milliseconds. Returns nullopt if the result is outside the Int32 year range.