Represents a date and a time in the form of year_month_day and hh_mm_ss.
More...
#include <datetime.hpp>
|
| | Datetime ()=delete |
| template<IsDuration Duration> |
| constexpr | Datetime (const time_point< system_clock, Duration > &tp) |
| | Constructs a Datetime from a time_point.
|
| template<IsDuration Duration> |
| constexpr | Datetime (const year_month_day &ymd, const Duration elapsed) |
| | Constructs a Datetime from a date and a raw duration since the start of that day.
|
| constexpr | Datetime (const year_month_day &ymd, double fraction) |
| | Constructs a Datetime from a year_month_day and a fraction of a day.
|
| constexpr auto | ok () const noexcept -> bool |
| | Checks if the underlying gregorian date and time are valid and within the supported range.
|
| constexpr auto | year () const noexcept -> int32_t |
| | Returns the year.
|
| constexpr auto | month () const noexcept -> uint32_t |
| | Returns the month.
|
| constexpr auto | day () const noexcept -> uint32_t |
| | Returns the day.
|
| constexpr auto | fraction () const noexcept -> double |
| | Returns the fraction of a day, in the range [0.0, 1.0).
|
| constexpr auto | operator== (const Datetime &other) const noexcept -> bool |
| constexpr auto | operator<=> (const Datetime &other) const noexcept |
Represents a date and a time in the form of year_month_day and hh_mm_ss.
- Note
- The precision of the time_of_day field is std::chrono::nanoseconds.
-
The time_of_day field (i.e. hh_mm_ss) is positive and less than 24:00:00.0 (i.e. 1 day).
-
No time zone is assumed.
This struct is used to represent UT1, UTC, and TT time in this project.
◆ Datetime() [1/4]
| calendar::Datetime::Datetime |
( |
| ) |
|
|
delete |
◆ Datetime() [2/4]
template<IsDuration Duration>
| calendar::Datetime::Datetime |
( |
const time_point< system_clock, Duration > & | tp | ) |
|
|
inlineexplicitconstexpr |
Constructs a Datetime from a time_point.
- Parameters
-
- Exceptions
-
| std::invalid_argument | If the input is non-finite, outside the Gregorian year range, or cannot be represented during conversion. |
- Note
- Floating-point rounding can make the day remainder unrepresentable near midnight; such inputs are rejected.
◆ Datetime() [3/4]
template<IsDuration Duration>
| calendar::Datetime::Datetime |
( |
const year_month_day & | ymd, |
|
|
const Duration | elapsed ) |
|
inlineexplicitconstexpr |
Constructs a Datetime from a date and a raw duration since the start of that day.
- Parameters
-
| ymd | The year, month, and day. |
| elapsed | The finite time of day in [0, 24h), checked before and after conversion to nanoseconds. |
- Exceptions
-
| std::invalid_argument | If the date is invalid, the duration is non-finite, or the original or converted duration is outside [0, 24h). |
◆ Datetime() [4/4]
| calendar::Datetime::Datetime |
( |
const year_month_day & | ymd, |
|
|
double | fraction ) |
|
inlineexplicitconstexpr |
Constructs a Datetime from a year_month_day and a fraction of a day.
- Parameters
-
| ymd | The year, month, and day. |
| fraction | The fraction of a day, in the range [0.0, 1.0). |
◆ day()
| auto calendar::Datetime::day |
( |
| ) |
const->uint32_t |
|
inlinenodiscardconstexprnoexcept |
◆ fraction()
| auto calendar::Datetime::fraction |
( |
| ) |
const->double |
|
inlinenodiscardconstexprnoexcept |
Returns the fraction of a day, in the range [0.0, 1.0).
- Returns
- The fraction of a day, expected to be in the range [0.0, 1.0).
◆ month()
| auto calendar::Datetime::month |
( |
| ) |
const->uint32_t |
|
inlinenodiscardconstexprnoexcept |
◆ ok()
| auto calendar::Datetime::ok |
( |
| ) |
const->bool |
|
inlinenodiscardconstexprnoexcept |
Checks if the underlying gregorian date and time are valid and within the supported range.
- Returns
- true if all good, false otherwise.
◆ operator<=>()
| auto calendar::Datetime::operator<=> |
( |
const Datetime & | other | ) |
const |
|
inlinenodiscardconstexprnoexcept |
◆ operator==()
| auto calendar::Datetime::operator== |
( |
const Datetime & | other | ) |
const->bool |
|
inlinenodiscardconstexprnoexcept |
◆ year()
| auto calendar::Datetime::year |
( |
| ) |
const->int32_t |
|
inlinenodiscardconstexprnoexcept |
◆ time_of_day
◆ ymd
The documentation for this struct was generated from the following file: