Hegel 0.18.3
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::generators::temporal::SignedDuration Struct Reference

A signed duration: seconds plus nanoseconds of the same sign, the latter within ±999999999, so -1.5 s is {-1, -500000000}. More...

#include <temporal_types.h>

Public Member Functions

template<typename Duration = std::chrono::nanoseconds>
std::optional< Duration > to_chrono () const
 The same duration as a std::chrono::duration, or std::nullopt when it is not a whole number of the duration's units or does not fit in its representation.

Static Public Member Functions

template<typename Rep, typename Period>
static std::optional< SignedDuration > from_chrono (std::chrono::duration< Rep, Period > duration)
 The SignedDuration of a std::chrono::duration, or std::nullopt when its seconds do not fit in int64_t.

Public Attributes

int64_t seconds = 0
 Whole seconds.
int32_t nanoseconds = 0
 Nanoseconds, of the sign of seconds.

Detailed Description

A signed duration: seconds plus nanoseconds of the same sign, the latter within ±999999999, so -1.5 s is {-1, -500000000}.

Prints in the ISO 8601 duration form PT1H30M5.5S, with a leading - when negative and PT0S for zero.

Member Function Documentation

◆ from_chrono()

template<typename Rep, typename Period>
std::optional< SignedDuration > hegel::generators::temporal::SignedDuration::from_chrono ( std::chrono::duration< Rep, Period > duration)
inlinestatic

The SignedDuration of a std::chrono::duration, or std::nullopt when its seconds do not fit in int64_t.

Parameters
durationThe duration to convert.
Returns
The duration, or std::nullopt.

◆ to_chrono()

template<typename Duration = std::chrono::nanoseconds>
std::optional< Duration > hegel::generators::temporal::SignedDuration::to_chrono ( ) const
inline

The same duration as a std::chrono::duration, or std::nullopt when it is not a whole number of the duration's units or does not fit in its representation.

Template Parameters
DurationA std::chrono::duration whose period is a standard unit; std::chrono::nanoseconds by default.
Returns
The duration, or std::nullopt.

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