AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::date::OffsetTime Class Reference

Time of day with an offset from UTC (RFC 3339 full-time , time format of JSON schema and OpenAPI). More...

#include <offsetTime.hpp>

Collaboration diagram for anch::date::OffsetTime:

Public Member Functions

constexpr OffsetTime () noexcept
 OffsetTime (const anch::date::Time &time, std::chrono::minutes offset)
std::string format () const
constexpr const anch::date::Time & time () const noexcept
constexpr std::chrono::minutes offset () const noexcept
anch::date::Time utc () const noexcept
OffsetTime withOffset (std::chrono::minutes offset) const
constexpr bool isSameInstant (const OffsetTime &other) const noexcept
constexpr std::strong_ordering operator<=> (const OffsetTime &other) const noexcept
constexpr bool operator== (const OffsetTime &other) const noexcept

Static Public Member Functions

static OffsetTime now (anch::date::Zone zone=anch::date::Zone::LOCAL)
static OffsetTime parse (std::string_view text)

Detailed Description

Time of day with an offset from UTC (RFC 3339 full-time , time format of JSON schema and OpenAPI).

A time of day ( Time ) and a fixed offset from UTC, from -23:59 to +23:59 (minutes: RFC 3339 offsets have no seconds). Named time zones are not kept: a time of day without day has no offset in a time zone with daylight saving time.
Equality compares the time and the offset ( 12:00+01:00 is not 11:00Z , see isSameInstant ) ; order compares the UTC times on the same day ( 23:00-02:00 is after 00:30Z ), then the local times.
A day and an offset time give a point in time without time zone ( Date::at ).

Author
Vincent Lachenal
Since
0.3

Constructor & Destructor Documentation

◆ OffsetTime() [1/2]

anch::date::OffsetTime::OffsetTime ( )
constexprnoexcept

OffsetTime default constructor: midnight UTC ( 00:00:00Z )

◆ OffsetTime() [2/2]

anch::date::OffsetTime::OffsetTime ( const anch::date::Time & time,
std::chrono::minutes offset )

OffsetTime constructor

Parameters
timethe time of day (local time of the offset)
offsetthe offset from UTC (from -23:59 to +23:59)
Exceptions
std::invalid_argumentoffset out of range
Here is the call graph for this function:

Member Function Documentation

◆ format()

std::string anch::date::OffsetTime::format ( ) const

Format RFC 3339 full-time ( Z for UTC, fraction of 0, 3, 6 or 9 digits)

Returns
the formatted time
Here is the call graph for this function:

◆ isSameInstant()

bool anch::date::OffsetTime::isSameInstant ( const OffsetTime & other) const
constexprnoexcept

Check if times are the same instant (same UTC time on the same day, offsets can be different)

Parameters
otherthe other time
Returns
true when 12:00+01:00 and 11:00Z for example
Here is the call graph for this function:

◆ now()

OffsetTime anch::date::OffsetTime::now ( anch::date::Zone zone = anch::date::Zone::LOCAL)
static

Current time of day with the offset of a time zone

Parameters
zonethe time zone (default local time ; historic offsets with seconds are truncated to the minute)
Returns
the current time
Here is the call graph for this function:

◆ offset()

std::chrono::minutes anch::date::OffsetTime::offset ( ) const
constexprnoexcept

Offset getter

Returns
the offset from UTC
Here is the call graph for this function:

◆ operator<=>()

std::strong_ordering anch::date::OffsetTime::operator<=> ( const OffsetTime & other) const
constexprnoexcept

Compare UTC times on the same day, then local times

Parameters
otherthe other time
Returns
the comparison
Here is the call graph for this function:

◆ operator==()

bool anch::date::OffsetTime::operator== ( const OffsetTime & other) const
constexprnoexcept

Same time and same offset

Parameters
otherthe other time
Returns
true when time and offset are equal
Here is the call graph for this function:

◆ parse()

OffsetTime anch::date::OffsetTime::parse ( std::string_view text)
static

Parse RFC 3339 full-time ( HH:MM:SS[.fraction](Z|+HH:MM|-HH:MM) , see rfc3339::parseFullTime )

Parameters
textthe text to parse
Returns
the time
Exceptions
std::invalid_argumentinvalid format, impossible time or leap second
Here is the call graph for this function:

◆ time()

const anch::date::Time & anch::date::OffsetTime::time ( ) const
constexprnoexcept

Time of day getter

Returns
the time of day (local time of the offset)
Here is the call graph for this function:

◆ utc()

anch::date::Time anch::date::OffsetTime::utc ( ) const
noexcept

UTC time of day

Returns
the time of day in UTC (modulo midnight: 00:30+01:00 is 23:30 UTC)
Here is the call graph for this function:

◆ withOffset()

OffsetTime anch::date::OffsetTime::withOffset ( std::chrono::minutes offset) const

Same instant with another offset

Parameters
offsetthe offset from UTC (from -23:59 to +23:59)
Returns
the time with this offset (modulo midnight)
Exceptions
std::invalid_argumentoffset out of range
Here is the call graph for this function:

The documentation for this class was generated from the following file: