CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
util Namespace Reference

Namespaces

namespace  cache
namespace  hash
namespace  ymd_operator

Concepts

concept  YearConvertible
 An integral year of at most 64 value bits, a floating-point year, or a chrono year.
concept  DaysConvertible
 A type std::chrono::days can be built from — what the operators below shift by.

Functions

constexpr auto checked_year (const int32_t year) -> std::chrono::year
 Converts an integer year to std::chrono::year, rejecting what narrowing would alias.
constexpr auto to_ymd (const YearConvertible auto year, const uint32_t month, const uint32_t day) -> std::chrono::year_month_day
 Converts the input year, month, and date to a std::chrono::year_month_day.
constexpr auto from_ymd (const std::chrono::year_month_day &ymd) -> std::tuple< int32_t, uint32_t, uint32_t >
 Converts the input std::chrono::year_month_day to a year, month, and date.

Function Documentation

◆ checked_year()

auto util::checked_year ( const int32_t year) ->std::chrono::year
nodiscardconstexpr

Converts an integer year to std::chrono::year, rejecting what narrowing would alias.

Parameters
yearThe original integer year.
Returns
The same year as a std::chrono::year.
Exceptions
std::invalid_argumentIf year is outside [std::chrono::year::min(), std::chrono::year::max()]; the diagnostic names the original integer.
Note
std::chrono::year holds an unspecified value outside ±32767; the check precedes the narrowing conversion.

◆ from_ymd()

auto util::from_ymd ( const std::chrono::year_month_day & ymd) ->std::tuple< int32_t, uint32_t, uint32_t >
nodiscardconstexpr

Converts the input std::chrono::year_month_day to a year, month, and date.

◆ to_ymd()

auto util::to_ymd ( const YearConvertible auto year,
const uint32_t month,
const uint32_t day )->std::chrono::year_month_day
nodiscardconstexpr

Converts the input year, month, and date to a std::chrono::year_month_day.

Exceptions
std::invalid_argumentif the original year is not a representable whole year, or month/day cannot be represented unchanged by their chrono fields.
Note
Calendar validity is checked by the consumer: lunar labels also use positional month 13.