AnCH date library aims to provide facilities for applications manipulate date/time.
None
CMake target anch::date:
See installation.
anch::date::DateTime stores a point in time (nanoseconds since epoch, nothing else): its broken down representation ( anch::date::DateFields : local time or UTC) is computed by fields . It is epoch by default, DateTime::now gives the current time ; it can be built from std::chrono::system_clock::time_point , std::time_t , std::tm (local time), std::timespec and local anch::date::DateFields , and explicitly converted to these types. Points in time are ordered.
Local time follows the TZ environment variable, daylight saving time included.
anch::date::DateFormatter formats and parses dates with patterns: %Y , %y , %m , %d , %H , %h (12 hours), %p (a.m./p.m.), %M , %S and %s (milliseconds). Other patterns can be added by implementing anch::date::IDatePartFormatter (on anch::date::DateFields ) and registering it with anch::date::DateFormatter::registerFormatterPart .
Parsing is strict: every field has a fixed size, constant parts have to match and impossible dates are refused.
For simple formatting, std::format with std::chrono specifiers can also be used on the converted time point.
anch::date::rfc3339 formats and parses RFC 3339 dates (JSON schema and OpenAPI date-time , date and time formats): date-time is a anch::date::DateTime (written in UTC or with the local offset), full-date is a anch::date::Date , partial-time a anch::date::Time and full-time an anch::date::OffsetTime . anch-json uses them for these types when ANCH_DATE is ON .
anch::date::Date is a calendar day (0000-01-01 to 9999-12-31, always valid): it is not a point in time, its conversions to and from anch::date::DateTime give the time zone ( anch::date::Zone ). Dates are ordered, days, months and years can be added:
anch::date::Time is a time of day (00:00:00 to 23:59:59.999999999, RFC 3339 partial-time , SQL TIME ), without time zone either:
anch::date::OffsetTime is a time of day with a fixed offset from UTC (-23:59 to +23:59, RFC 3339 full-time , JSON schema and OpenAPI time format): equality compares the time and the offset, isSameInstant the UTC times ; a day and an offset time give a point in time without time zone: