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

A proleptic Gregorian calendar date. More...

#include <temporal_types.h>

Public Member Functions

template<typename YearMonthDay>
std::optional< YearMonthDay > to_chrono () const
 The same date as a calendar date of another library, or std::nullopt when the year lies outside the range of that library's year.

Static Public Member Functions

template<typename YearMonthDay>
static std::optional< Date > from_chrono (const YearMonthDay &ymd)
 The Date of a calendar date of another library, or std::nullopt when it is not a valid date (!ymd.ok()).

Public Attributes

int32_t year = 1970
 The year, negative before year 0.
uint8_t month = 1
 The month, 1 for January.
uint8_t day = 1
 The day of the month, from 1.

Detailed Description

A proleptic Gregorian calendar date.

year is in [MIN_YEAR, MAX_YEAR] (±999,999), month in [1, 12] and day in [1, days in the month]. Prints as 2024-03-10, with a six-digit signed year outside 0000 to 9999.

Member Function Documentation

◆ from_chrono()

template<typename YearMonthDay>
std::optional< Date > hegel::generators::temporal::Date::from_chrono ( const YearMonthDay & ymd)
inlinestatic

The Date of a calendar date of another library, or std::nullopt when it is not a valid date (!ymd.ok()).

Template Parameters
YearMonthDaystd::chrono::year_month_day (C++20), or a type with its interface, such as date::year_month_day.
Parameters
ymdThe date to convert.
Returns
The date, or std::nullopt.

◆ to_chrono()

template<typename YearMonthDay>
std::optional< YearMonthDay > hegel::generators::temporal::Date::to_chrono ( ) const
inline

The same date as a calendar date of another library, or std::nullopt when the year lies outside the range of that library's year.

auto ymd = date.to_chrono<std::chrono::year_month_day>();
Template Parameters
YearMonthDaystd::chrono::year_month_day (C++20), or a type with its interface, such as date::year_month_day.
Returns
The date, or std::nullopt.

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