Time of day with an offset from UTC (RFC 3339 full-time , time format of JSON schema and OpenAPI).
More...
#include <offsetTime.hpp>
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
◆ 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
-
| time | the time of day (local time of the offset) |
| offset | the offset from UTC (from -23:59 to +23:59) |
- Exceptions
-
| std::invalid_argument | offset out of range |
◆ 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
◆ 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
-
- Returns
true when 12:00+01:00 and 11:00Z for example
◆ now()
Current time of day with the offset of a time zone
- Parameters
-
| zone | the time zone (default local time ; historic offsets with seconds are truncated to the minute) |
- Returns
- the current time
◆ offset()
| std::chrono::minutes anch::date::OffsetTime::offset |
( |
| ) |
const |
|
constexprnoexcept |
Offset getter
- Returns
- the offset from UTC
◆ operator<=>()
| std::strong_ordering anch::date::OffsetTime::operator<=> |
( |
const OffsetTime & | other | ) |
const |
|
constexprnoexcept |
Compare UTC times on the same day, then local times
- Parameters
-
- Returns
- the comparison
◆ operator==()
| bool anch::date::OffsetTime::operator== |
( |
const OffsetTime & | other | ) |
const |
|
constexprnoexcept |
Same time and same offset
- Parameters
-
- Returns
true when time and offset are equal
◆ 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
-
- Returns
- the time
- Exceptions
-
| std::invalid_argument | invalid format, impossible time or leap second |
◆ time()
Time of day getter
- Returns
- the time of day (local time of the offset)
◆ utc()
UTC time of day
- Returns
- the time of day in UTC (modulo midnight:
00:30+01:00 is 23:30 UTC)
◆ withOffset()
| OffsetTime anch::date::OffsetTime::withOffset |
( |
std::chrono::minutes | offset | ) |
const |
Same instant with another offset
- Parameters
-
| offset | the offset from UTC (from -23:59 to +23:59) |
- Returns
- the time with this offset (modulo midnight)
- Exceptions
-
| std::invalid_argument | offset out of range |
The documentation for this class was generated from the following file: