Point in time. More...
#include <dateTime.hpp>
Public Member Functions | |
| constexpr | DateTime () noexcept |
| DateTime (const std::chrono::system_clock::time_point &time) | |
| DateTime (const std::time_t &time) | |
| DateTime (const std::tm *const time) | |
| DateTime (const std::timespec &time) | |
| DateTime (const anch::date::DateFields &fields) | |
| anch::date::DateFields | fields (anch::date::Zone zone=anch::date::Zone::LOCAL) const |
| bool | after (const DateTime &date) const noexcept |
| bool | before (const DateTime &date) const noexcept |
| bool | equals (const DateTime &date) const noexcept |
| anch::date::Date | date (anch::date::Zone zone=anch::date::Zone::LOCAL) const |
| anch::date::Time | time (anch::date::Zone zone=anch::date::Zone::LOCAL) const |
| anch::date::OffsetTime | offsetTime (anch::date::Zone zone=anch::date::Zone::LOCAL) const |
| std::strong_ordering | operator<=> (const DateTime &date) const noexcept |
| bool | operator== (const DateTime &date) const noexcept |
| operator std::chrono::system_clock::time_point () const noexcept | |
| operator std::time_t () const noexcept | |
| operator std::tm () const noexcept | |
| operator std::timespec () const noexcept | |
Static Public Member Functions | |
| static DateTime | now () |
Point in time.
A DateTime is a point in time with a nanosecond precision, stored as a number of nanoseconds since epoch (which covers years 1678 to 2261). Its broken down representation ( fields ) is computed in local time or UTC: local time is computed with localtime_r (std::chrono time zones are not available with GCC 13): it is thread safe and follows the TZ environment variable.
A default DateTime is epoch: the current time is now . DateTime can be converted from and to std::chrono::system_clock::time_point , std::time_t , std::tm and std::timespec . Its day is a Date ( date ).
|
constexprnoexcept |
|
explicit |
DateTime constructor
| time | the time point to set |
|
explicit |
DateTime constructor
| time | the time to set |
| std::invalid_argument | date out of range (years 1678 to 2261: timestamps are stored in nanoseconds) |
|
explicit |
DateTime constructor
| time | the local time to set (tm_isdst has to be -1 when daylight saving time is unknown ; tm_wday and tm_yday are ignored ; out of range fields are normalized as std::mktime does) |
| std::invalid_argument | date out of range (years 1678 to 2261) |
|
explicit |
DateTime constructor
| time | the time to set (tv_nsec in [0, 999999999]) |
| std::invalid_argument | date out of range (years 1678 to 2261) or invalid tv_nsec |
|
explicit |
DateTime constructor
| fields | the local time (out of range fields are normalized as std::mktime does ; weekday and yearday are ignored) |
| std::invalid_argument | date out of range (years 1678 to 2261) |
|
noexcept |
|
noexcept |
| anch::date::Date anch::date::DateTime::date | ( | anch::date::Zone | zone = anch::date::Zone::LOCAL | ) | const |
Day of this point in time
| zone | the time zone of the day (default local time) |
|
noexcept |
| anch::date::DateFields anch::date::DateTime::fields | ( | anch::date::Zone | zone = anch::date::Zone::LOCAL | ) | const |
Broken down date and time
| zone | the time zone (default local time) |
|
static |
Current point in time
| anch::date::OffsetTime anch::date::DateTime::offsetTime | ( | anch::date::Zone | zone = anch::date::Zone::LOCAL | ) | const |
Time of day of this point in time with the offset of a time zone
| zone | the time zone (default local time ; historic offsets with seconds are truncated to the minute, the written time is shifted, as rfc3339::formatDateTime does) |
|
explicitnoexcept |
Cast operator to std::chrono::system_clock::time_point
|
explicitnoexcept |
Cast operator to std::time_t (sub-second part is truncated toward the past)
std::time_t
|
explicitnoexcept |
Cast operator to std::timespec
std::timespec
|
explicitnoexcept |
Cast operator to std::tm (local time, with tm_wday , tm_yday and tm_isdst )
std::tm
|
noexcept |
Compare dates (with nanosecond precision)
| date | the date to compare to |
|
noexcept |
Check if dates are equals (with nanosecond precision)
| date | the date to compare to |
true when dates are equals, false otherwise | anch::date::Time anch::date::DateTime::time | ( | anch::date::Zone | zone = anch::date::Zone::LOCAL | ) | const |
Time of day of this point in time
| zone | the time zone (default local time) |