An instant.
More...
#include <temporal_types.h>
|
| template<typename Duration> |
| std::optional< std::chrono::time_point< std::chrono::system_clock, Duration > > | to_chrono () const |
| | The same instant as a std::chrono::system_clock time point, or std::nullopt when it is not a whole number of the duration's units or does not fit in its representation.
|
|
| template<typename Rep, typename Period> |
| static std::optional< Instant > | from_chrono (std::chrono::time_point< std::chrono::system_clock, std::chrono::duration< Rep, Period > > time_point) |
| | The Instant of a std::chrono::system_clock time point, or std::nullopt when it lies outside [MIN_INSTANT,
MAX_INSTANT].
|
|
|
int64_t | second = 0 |
| | Seconds since 1970-01-01T00:00:00Z.
|
|
uint32_t | nanosecond = 0 |
| | Nanoseconds after second.
|
An instant.
seconds since the Unix epoch in [MIN_INSTANT, MAX_INSTANT] (the civil range of Date, about ±3.2 × 10¹³ seconds) and a nanosecond in [0, 999999999] counted forward from that second, so -1.5 s is {-2, 500000000}. Prints as the UTC wall time with a Z suffix: 2000-01-01T00:00:00Z.
◆ from_chrono()
template<typename Rep, typename Period>
| std::optional< Instant > hegel::generators::temporal::Instant::from_chrono |
( |
std::chrono::time_point< std::chrono::system_clock, std::chrono::duration< Rep, Period > > | time_point | ) |
|
|
inlinestatic |
The Instant of a std::chrono::system_clock time point, or std::nullopt when it lies outside [MIN_INSTANT,
MAX_INSTANT].
- Parameters
-
| time_point | The time point to convert. |
- Returns
- The instant, or std::nullopt.
◆ to_chrono()
template<typename Duration>
| std::optional< std::chrono::time_point< std::chrono::system_clock, Duration > > hegel::generators::temporal::Instant::to_chrono |
( |
| ) |
const |
|
inline |
The same instant as a std::chrono::system_clock time point, or std::nullopt when it is not a whole number of the duration's units or does not fit in its representation.
The range of Instant is wider than that of most time points: a 64-bit count of nanoseconds holds the years 1678 to 2262 only, and one of microseconds about ±292,000 years. Bound the generator, or name a coarser duration, when the conversion must succeed, or draw the time point itself with instants<TimePoint>(), which draws only instants the type holds.
auto at = instant.to_chrono<std::chrono::system_clock::duration>();
- Template Parameters
-
| Duration | A std::chrono::duration whose period is a standard unit, such as std::chrono::seconds. |
- Returns
- The time point, or std::nullopt.
The documentation for this struct was generated from the following file: