CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
datetime.hpp File Reference
#include <cmath>
#include <chrono>
#include <format>
#include <cassert>
#include <cstdint>
#include <concepts>
#include <limits>
#include <ratio>
#include <stdexcept>
#include <type_traits>
#include <functional>
#include "ymd.hpp"

Classes

struct  calendar::Datetime
 Represents a date and a time in the form of year_month_day and hh_mm_ss. More...

Namespaces

namespace  calendar
namespace  calendar::detail

Concepts

concept  calendar::IsDuration
 Checks if a type is of std::chrono::duration.
concept  calendar::Fractionable
 Checks if a type can cast to std::chrono::nanoseconds, which is the assumption of function fraction.

Typedefs

using calendar::days
using calendar::seconds
using calendar::nanoseconds
using calendar::microseconds
using calendar::system_clock
using calendar::year_month_day
using calendar::sys_days

Functions

template<IsDuration Duration>
consteval auto calendar::in_a_day () -> uint64_t
 Returns the number of the given duration in a day.
template<IsDuration From, IsDuration To>
constexpr auto calendar::detail::checked_duration_cast (const From elapsed) -> To
 Cast an arithmetic duration to a signed integral duration without overflowing intermediates.
template<IsDuration Duration>
constexpr auto calendar::detail::checked_time_of_day (const Duration elapsed) -> nanoseconds
 Validate the original and converted day durations and return the nanosecond count.
template<IsDuration Duration>
requires std::integral<typename Duration::rep>
constexpr auto calendar::detail::checked_day (const Duration elapsed) -> days
 Floor an integral epoch duration to a day within the Gregorian year range.
template<IsDuration Duration>
requires std::floating_point<typename Duration::rep>
constexpr auto calendar::detail::checked_day (const Duration elapsed) -> days
 Floor a floating epoch duration, checking the original and rounded day ranges.
template<IsDuration Duration>
requires std::integral<typename Duration::rep>
constexpr auto calendar::detail::time_of_day (const Duration elapsed, const days day) -> nanoseconds
 Return the checked day remainder without overflowing integral intermediates.
template<IsDuration Duration>
requires std::floating_point<typename Duration::rep>
constexpr auto calendar::detail::time_of_day (const Duration elapsed, const days day) -> nanoseconds
 Reject unrepresentable floating remainders of an epoch duration.
template<Fractionable Duration>
constexpr auto calendar::to_fraction (const Duration &elapsed) -> double
 Returns the fraction of a day.
constexpr auto calendar::from_fraction (const double fraction) -> hh_mm_ss< nanoseconds >
 Returns the nanoseconds of fraction days.
constexpr auto calendar::validate_fraction (const double fraction) -> double
 Validate the fraction of a day, before any narrowing conversion happens.
constexpr auto calendar::add_seconds (const Datetime &dt, const double offset_sec) -> Datetime
 Returns dt shifted by offset_sec seconds, carrying whole days into the date part.

Variables

constexpr auto calendar::detail::FIRST_GREGORIAN_DAY
constexpr auto calendar::detail::END_GREGORIAN_DAY