ORIGINAL
|
Represents a UTC calendar date and time. More...
#include <zeit.h>
Public Member Functions | |
bool | isLeapYear () const |
Checks if this year is a leap year. | |
weekdays | weekday () const |
Gets weekday for this date. | |
UTCTime () | |
Constructs a UTCTime object representing the epoch (1970-01-01 00:00:00 UTC) | |
UTCTime (integer year, integer month, integer day) | |
Constructs a UTCTime object with specified date components (time set to 00:00:00) | |
UTCTime (integer year, integer month, integer day, integer hour, integer minute, integer second) | |
Constructs a UTCTime object with all date and time components. | |
UTCTime (const point &p) | |
Constructs a UTCTime object from a time point. | |
UTCTime (const UTCTime &other)=default | |
Default copy constructor. | |
UTCTime & | operator= (const UTCTime &other)=default |
Default copy assignment. | |
UTCTime (UTCTime &&other) noexcept | |
Move constructor. | |
UTCTime & | operator= (UTCTime &&other) noexcept |
Move assignment. | |
UTCTime | date () const |
Returns a new UTCTime object containing only the calendar date. | |
integer | value (unit unit) const |
Gets time component value. | |
integer | value (calendar calendar) const |
Gets calendar component value. | |
operator point () const | |
Converts to time::point. | |
point | toPoint () const |
integer | compareTo (const UTCTime &other) const override |
Compares this UTCTime to another. | |
u_integer | toHash () const noexcept override |
Computes hash value for this UTCTime. | |
std::string | className () const override |
Gets the class name. | |
std::string | toString (bool enter) const override |
Converts UTCTime to string representation (YYYY-MM-DD HH:MM:SS) | |
![]() | |
virtual integer | compareTo (const UTCTime &other) const=0 |
Compares the current object with another of the same type. | |
bool | operator== (const UTCTime &other) const |
Checks if the current object is equal to another. | |
bool | operator!= (const UTCTime &other) const |
Checks if the current object is not equal to another. | |
bool | operator< (const UTCTime &other) const |
Checks if the current object is less than another. | |
bool | operator> (const UTCTime &other) const |
Checks if the current object is greater than another. | |
bool | operator<= (const UTCTime &other) const |
Checks if the current object is less than or equal to another. | |
bool | operator>= (const UTCTime &other) const |
Checks if the current object is greater than or equal to another. | |
virtual | ~comparable ()=default |
Virtual destructor for proper cleanup of derived objects. | |
![]() | |
virtual bool | equals (const UTCTime &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (bool enter) const |
Direct C-string access with formatting control. | |
template<typename TYPE > | |
auto | formatString (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatCString (const TYPE &t) -> const char * |
template<typename TYPE > | |
auto | formatEnum (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatString (TYPE *const &ptr) -> std::string |
Static Public Member Functions | |
static UTCTime | now () |
Gets current UTC time. | |
static integer | localZonedOffset () |
Returns the system's local timezone offset in hours from UTC. | |
static UTCTime | localNow () |
Returns the current local time as UTCTime. | |
static constexpr bool | isLeapYear (integer year) |
Checks if year is a leap year. | |
static constexpr integer | daysOfMonth (integer year, integer month) |
Gets days in specified month. | |
static constexpr weekdays | weekday (integer year, integer month, integer day) |
Calculates weekday for given date. | |
static constexpr bool | isValidYMD (integer year, integer month, integer day) |
Checks if year-month-day is valid. | |
static constexpr bool | isValidHMS (integer hour, integer minute, integer second) |
Checks if hour-minute-second is valid. | |
static constexpr bool | isValid (integer year, integer month, integer day, integer hour, integer minute, integer second) |
Checks if full date-time is valid. | |
![]() | |
template<typename TYPE > | |
static std::string | formatString (const TYPE &t) |
Universal value-to-string conversion with type-specific formatting. | |
template<Printable TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for types deriving from printable. | |
template<EnumType TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for enum types with type-safe formatting. | |
template<typename TYPE > | |
static std::string | formatString (TYPE *const &ptr) |
Pointer-specific formatting with null safety. | |
template<typename TYPE > | |
static const char * | formatCString (const TYPE &t) |
C-string cache for temporary usage with static storage. | |
template<typename TYPE > | |
static std::string | formatEnum (const TYPE &t) |
Enum formatting utility with underlying value extraction. | |
template<> | |
auto | formatString (const char &t) -> std::string |
template<> | |
auto | formatString (const bool &t) -> std::string |
template<> | |
auto | formatString (const char *const &ptr) -> std::string |
Public Attributes | |
friend | time |
Static Public Attributes | |
static constexpr auto | SATURDAY = weekdays::SATURDAY |
Constant for Saturday. | |
static constexpr auto | SUNDAY = weekdays::SUNDAY |
Constant for Sunday. | |
static constexpr auto | MONDAY = weekdays::MONDAY |
Constant for Monday. | |
static constexpr auto | TUESDAY = weekdays::TUESDAY |
Constant for Tuesday. | |
static constexpr auto | WEDNESDAY = weekdays::WEDNESDAY |
Constant for Wednesday. | |
static constexpr auto | THURSDAY = weekdays::THURSDAY |
Constant for Thursday. | |
static constexpr auto | FRIDAY = weekdays::FRIDAY |
Constant for Friday. | |
static constexpr integer | DAYS_WEEK = 7 |
Days in a week. | |
static constexpr integer | MONTHS_YEAR = std::size(DAYS_OF_MONTH) |
Months in a year. | |
static constexpr integer | YEARS_CENTURY = 100 |
Years in a century. | |
static const UTCTime | EPOCH = UTCTime{} |
Epoch time constant (1970-01-01 00:00:00) | |
Friends | |
UTCTime | operator+ (const UTCTime &t, const duration &d) |
Adds duration to UTCTime. | |
UTCTime | operator+ (const duration &d, const UTCTime &t) |
Adds duration to UTCTime (Reversed version) | |
UTCTime | operator- (const UTCTime &t, const duration &d) |
Subtracts duration from UTCTime. | |
duration | operator- (const UTCTime &lhs, const UTCTime &rhs) |
Computes duration between two UTCTimes. | |
Represents a UTC calendar date and time.
Provides calendar operations including:
|
inlineexplicit |
Constructs a UTCTime object representing the epoch (1970-01-01 00:00:00 UTC)
Initializes all time components to zero, representing the Unix epoch.
Constructs a UTCTime object with specified date components (time set to 00:00:00)
year | The year component |
month | The month component (1-12) |
day | The day component (1-31, must be valid for month/year) |
valueError | if any component is invalid or date is impossible |
|
inlineexplicit |
Constructs a UTCTime object with all date and time components.
year | The year component (must be >= 1970) |
month | The month component (1-12) |
day | The day component (1-31, must be valid for month/year) |
hour | The hour component (0-23) |
minute | The minute component (0-59) |
second | The second component (0-59) |
valueError | if any component is invalid or datetime is impossible |
Constructs a UTCTime object from a time point.
p | The time point to convert from |
|
inlinenoexcept |
Move constructor.
other | UTCTime to move from |
|
inlineoverridevirtual |
|
inlineoverride |
|
inline |
Returns a new UTCTime object containing only the calendar date.
|
staticconstexpr |
Gets days in specified month.
year | Year (for leap year calculation) |
month | Month (1-12) |
valueError | if month is invalid |
|
inline |
Checks if this year is a leap year.
Checks if year is a leap year.
year | Year to check |
|
staticconstexpr |
Checks if full date-time is valid.
year | Year |
month | Month (1-12) |
day | Day (1-31) |
hour | Hour (0-23) |
minute | Minute (0-59) |
second | Second (0-59) |
|
staticconstexpr |
Checks if hour-minute-second is valid.
hour | Hour (0-23) |
minute | Minute (0-59) |
second | Second (0-59) |
|
staticconstexpr |
Checks if year-month-day is valid.
year | Year |
month | Month (1-12) |
day | Day (1-31) |
|
inlinestatic |
|
inlinestatic |
Returns the system's local timezone offset in hours from UTC.
|
inlinestatic |
Gets current UTC time.
|
inlineexplicit |
Converts to time::point.
|
inlinenoexcept |
|
inlineoverridevirtualnoexcept |
Computes hash value for this UTCTime.
Reimplemented from original::hashable< UTCTime >.
|
inlineoverridevirtual |
Converts UTCTime to string representation (YYYY-MM-DD HH:MM:SS)
enter | Whether to include newline |
Reimplemented from original::printable.
|
inline |
Gets calendar component value.
calendar | Calendar component to get |
|
inline |
Gets time component value.
unit | Time unit to get |
|
inline |
Gets weekday for this date.
|
staticconstexpr |
Calculates weekday for given date.
year | Year |
month | Month (1-12) |
day | Day (1-31) |
valueError | if date is invalid |
Computes duration between two UTCTimes.
lhs | Left operand |
rhs | Right operand |