#include <gregorian.hpp>
|
enum class | Month {
January = 1
, February
, March
, April
,
May
, June
, July
, August
,
September
, October
, November
, December
} |
|
Definition at line 28 of file gregorian.hpp.
◆ Month
Enumerator |
---|
January | |
February | |
March | |
April | |
May | |
June | |
July | |
August | |
September | |
October | |
November | |
December | |
Definition at line 32 of file gregorian.hpp.
32 {
33 January = 1,
34 February,
35 March,
36 April,
37 May,
38 June,
39 July,
40 August,
41 September,
42 October,
43 November,
44 December
45 };
◆ days_in_month()
u8 mtcore::calendars::systems::Gregorian::days_in_month |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Definition at line 122 of file gregorian.hpp.
static constexpr u8 days_in_month_for(const AstronomicalYear year, const Month month)
◆ days_in_month_for()
static constexpr u8 mtcore::calendars::systems::Gregorian::days_in_month_for |
( |
const AstronomicalYear | year, |
|
|
const Month | month ) |
|
inlinestaticnodiscardconstexpr |
Definition at line 124 of file gregorian.hpp.
124 {
126 case Month::January:
127 case Month::March:
128 case Month::May:
129 case Month::July:
130 case Month::August:
131 case Month::October:
132 case Month::December:
133 return 31;
134 case Month::February:
136 case Month::April:
137 case Month::June:
138 case Month::September:
139 case Month::November:
140 return 30;
141 }
143 }
#define unreachable(...)
Marks code as unreachable.
static constexpr bool is_leap_year(const AstronomicalYear year)
◆ days_in_year()
u16 mtcore::calendars::systems::Gregorian::days_in_year |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Definition at line 113 of file gregorian.hpp.
static constexpr u16 days_in_year_for(const AstronomicalYear year)
◆ days_in_year_for()
static constexpr u16 mtcore::calendars::systems::Gregorian::days_in_year_for |
( |
const AstronomicalYear | year | ) |
|
|
inlinestaticnodiscardconstexpr |
Definition at line 115 of file gregorian.hpp.
115 {
117 return 366;
118 }
119 return 365;
120 }
◆ from_fixed()
static constexpr Gregorian mtcore::calendars::systems::Gregorian::from_fixed |
( |
const Fixed & | f | ) |
|
|
inlinestaticnodiscardconstexpr |
Definition at line 99 of file gregorian.hpp.
99 {
100 const auto year = year_from_fixed(f);
102 const auto yearStartRdDate = yearStart.to_fixed();
103 const auto priorDays = f.day_difference(yearStartRdDate);
104 const auto marchFirst = Gregorian{
year, Month::March, 1};
105 const auto marchFirstRdDate = marchFirst.to_fixed();
106 const auto correction = (f <=> marchFirstRdDate) == std::strong_ordering::less ? 0 :
is_leap_year(
year) ? 1 : 2;
108 const auto firstOfMonth = Gregorian{
year,
month, 1};
109 const auto firstOfMonthRdDate = firstOfMonth.to_fixed();
110 return Gregorian{
year,
month,
static_cast<u8>(f.day_difference(firstOfMonthRdDate) + 1)};
111 }
constexpr R floor(T num) noexcept
Floors a number with support for constexpr and fast runtime compilation.
uint8_t u8
Alias for 8-bit unsigned ints.
static constexpr Gregorian year_start_for(const AstronomicalYear year)
◆ init()
void mtcore::calendars::systems::Gregorian::init |
( |
i32 | year, |
|
|
Month | month, |
|
|
u8 | day ) |
|
inline |
◆ is_leap_year()
static constexpr bool mtcore::calendars::systems::Gregorian::is_leap_year |
( |
const AstronomicalYear | year | ) |
|
|
inlinestaticnodiscardconstexpr |
Definition at line 67 of file gregorian.hpp.
67 {
69 const auto yearMod400 =
math::mod(y, 400);
70 return math::mod(y, 4) == 0 && yearMod400 != 100 && yearMod400 != 200 && yearMod400 != 300;
71 }
i32 YearBase
Year base type.
constexpr Res mod(L left, R right) noexcept
Calculates the mathematical mod of two numbers.
◆ leap_year()
bool mtcore::calendars::systems::Gregorian::leap_year |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
◆ operator<=>()
std::strong_ordering mtcore::calendars::systems::Gregorian::operator<=> |
( |
const Gregorian & | g | ) |
const |
|
inlinenodiscardconstexpr |
Definition at line 57 of file gregorian.hpp.
57 {
58 if (
const auto c =
year <=> g.year; c != std::strong_ordering::equivalent) {
59 return c;
60 }
61 if (
const auto c =
month <=> g.month; c != std::strong_ordering::equivalent) {
62 return c;
63 }
65 }
◆ to_fixed()
Fixed mtcore::calendars::systems::Gregorian::to_fixed |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
Definition at line 87 of file gregorian.hpp.
87 {
95 : -2) +
97 }
int32_t i32
Alias for 32-bit ints.
static constexpr auto EPOCH
◆ year_end()
Gregorian mtcore::calendars::systems::Gregorian::year_end |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
◆ year_end_for()
|
inlinestaticnodiscardconstexpr |
Definition at line 81 of file gregorian.hpp.
81 {
82 return {.year =
year, .month = Month::December, .day = 31};
83 }
◆ year_start()
Gregorian mtcore::calendars::systems::Gregorian::year_start |
( |
| ) |
const |
|
inlinenodiscardconstexpr |
◆ year_start_for()
|
inlinestaticnodiscardconstexpr |
Definition at line 75 of file gregorian.hpp.
75 {
76 return {.year =
year, .month = Month::January, .day = 1};
77 }
◆ day
u8 mtcore::calendars::systems::Gregorian::day = 1 |
◆ EPOCH
◆ month
Month mtcore::calendars::systems::Gregorian::month = Month::January |
◆ name
std::string_view mtcore::calendars::systems::Gregorian::name = "Gregorian" |
|
staticconstexpr |
◆ year
The documentation for this struct was generated from the following file: