19#ifndef MTCORE_CALENDARS_CORE_HPP
20#define MTCORE_CALENDARS_CORE_HPP
42 explicit operator YearBase()
const {
return year; }
56 static bool is_valid(
const YearBase year) {
return year > std::numeric_limits<YearBase>::min(); }
89 inline AstronomicalYear::operator
AnnoDominiYear()
const {
return {year > 0 ? year : year - 1}; }
115 template<IsDayCalendarSystem Calendar>
127 template<
typename... Args>
133 cal = Calendar{args...};
138 template<
typename... Args>
145 template<IsDayCalendarSystem Other>
147 return {Other::from_fixed(
cal.to_fixed())};
155 template<IsDayCalendarSystem Other>
157 if constexpr (std::is_same_v<std::remove_cvref_t<Other>, std::remove_cvref_t<Calendar>>) {
161 return cal.to_fixed() <=> o.
cal.to_fixed();
164 template<IsDayCalendarSystem Other>
166 auto cmp = *this <=> o;
167 return cmp ==
decltype(cmp)::equivalent;
169 template<IsDayCalendarSystem Other>
171 auto cmp = *this <=> o;
172 return cmp !=
decltype(cmp)::equivalent;
174 template<IsDayCalendarSystem Other>
176 auto cmp = *this <=> o;
177 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::less;
179 template<IsDayCalendarSystem Other>
181 auto cmp = *this <=> o;
182 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::greater;
184 template<IsDayCalendarSystem Other>
186 auto cmp = *this <=> o;
187 return cmp ==
decltype(cmp)::less;
189 template<IsDayCalendarSystem Other>
191 auto cmp = *this <=> o;
192 return cmp ==
decltype(cmp)::greater;
206 return {Calendar::from_fixed(
cal.to_fixed().add_days(days))};
211 return {Calendar::from_fixed(
cal.to_fixed().sub_days(days))};
215 template<IsDayCalendarSystem Other>
217 return cal.to_fixed().day_difference(other.
cal.to_fixed());
222 return {Calendar::from_fixed(
cal.to_fixed().nth_week_day(n, k))};
227 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_before(k))};
232 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_after(k))};
237 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_nearest(k))};
242 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_on_or_before(k))};
247 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_on_or_after(k))};
252 return {Calendar::from_fixed(
cal.to_fixed().first_week_day(k))};
257 return {Calendar::from_fixed(
cal.to_fixed().last_week_day(k))};
275 template<IsDayCalendarSystem Other>
279 cal.to_fixed().positions_in_range(alloc, end.cal.to_fixed(), pthMoment, cDayCycle, delta);
281 return fixedRes.
error();
284 auto fixedDates = fixedRes.
value();
285 mtdefer { fixedDates.deinit(alloc); };
287 if (
const auto r = res.
init(alloc, fixedDates.size()); r.is_error()) {
291 auto iter = fixedDates.iter();
293 while (
iter.next().copy_if_present(cur)) {
315 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_on_or_before(k, m, offset))};
326 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_before(k, m, offset))};
337 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_on_or_after(k, m, offset))};
348 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_after(k, m, offset))};
359 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_nearest(k, m, offset))};
371 template<IsDayCalendarSystem Calendar>
386 auto nearestDate =
cal.to_fixed().day;
387 auto frac =
time.to_fraction_unchecked();
398 template<
typename Other>
401 return {Other::from_fixed(
cal.to_fixed()),
time};
404 Moment t = {
static_cast<f64>(
cal.to_fixed().day) +
time.to_fraction_unchecked()};
405 return {Other::from_moment(t)};
409 template<IsTimeCalendarSystem Other>
411 if constexpr (std::is_same_v<std::remove_cvref_t<Other>, std::remove_cvref_t<Calendar>>) {
412 if (
const std::partial_ordering cmp = cal <=> o.cal; cmp != std::partial_ordering::equivalent) {
415 return time <=> o.time;
418 if (
const std::partial_ordering cmp =
cal.to_moment() <=> o.cal.to_moment();
419 cmp != std::partial_ordering::equivalent) {
422 return time <=> o.time;
426 template<IsDayCalendarSystem Other>
428 if constexpr (std::is_same_v<std::remove_cvref_t<Other>, std::remove_cvref_t<Calendar>>) {
429 if (
const std::strong_ordering cmp = cal <=> o.cal; cmp != std::strong_ordering::equivalent) {
432 return time <=> o.time;
435 if (
const std::strong_ordering cmp =
cal.to_fixed() <=> o.cal.to_fixed();
436 cmp != std::strong_ordering::equivalent) {
439 return time <=> o.time;
443 template<
typename Other>
445 auto cmp = *this <=> o;
446 return cmp ==
decltype(cmp)::equivalent;
448 template<
typename Other>
450 auto cmp = *this <=> o;
451 return cmp !=
decltype(cmp)::equivalent;
453 template<
typename Other>
455 auto cmp = *this <=> o;
456 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::less;
458 template<
typename Other>
460 auto cmp = *this <=> o;
461 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::greater;
463 template<
typename Other>
465 auto cmp = *this <=> o;
466 return cmp ==
decltype(cmp)::less;
468 template<
typename Other>
470 auto cmp = *this <=> o;
471 return cmp ==
decltype(cmp)::greater;
479 return {Calendar::from_fixed(
cal.to_fixed().add_days(days))};
484 return {Calendar::from_fixed(
cal.to_fixed().sub_days(days))};
488 template<
typename Other>
491 return cal.to_fixed().day_difference(om.cal.to_fixed());
496 return {Calendar::from_fixed(
cal.to_fixed().nth_week_day(n, k))};
501 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_before(k))};
506 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_after(k))};
511 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_nearest(k))};
516 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_on_or_before(k))};
521 return {Calendar::from_fixed(
cal.to_fixed().day_of_week_on_or_after(k))};
526 return {Calendar::from_fixed(
cal.to_fixed().first_week_day(k))};
531 return {Calendar::from_fixed(
cal.to_fixed().last_week_day(k))};
549 template<
typename Other>
555 return fixedRes.
error();
558 auto fixedDates = fixedRes.
value();
559 mtdefer { fixedDates.deinit(alloc); };
561 if (
const auto r = res.
init(alloc, fixedDates.size()); r.is_error()) {
565 auto iter = fixedDates.iter();
567 while (
iter.next().copy_if_present(cur)) {
589 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_on_or_before(k, m, offset)),
time};
600 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_before(k, m, offset)),
time};
611 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_on_or_after(k, m, offset)),
time};
622 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_after(k, m, offset)),
time};
633 return {Calendar::from_fixed(
cal.to_fixed().kth_day_of_m_cycle_nearest(k, m, offset)),
time};
637 template<IsTimeCalendarSystem Calendar>
638 struct CalDateTime<Calendar> {
650 const auto m =
dateTime.to_moment();
659 template<
typename Other>
662 return {Other::from_moment(
dateTime.to_moment()),
time};
665 const auto m =
dateTime.to_moment();
669 Other::from_fixed(
Fixed{day}),
675 template<IsDayCalendarSystem Other>
681 template<IsTimeCalendarSystem Other>
683 if constexpr (std::is_same_v<std::remove_cvref_t<Other>, std::remove_cvref_t<Calendar>>) {
684 return dateTime <=> o.dateTime;
687 return dateTime.to_moment() <=> o.dateTime.to_moment();
691 template<
typename Other>
693 auto cmp = *this <=> o;
694 return cmp ==
decltype(cmp)::equivalent;
696 template<
typename Other>
698 auto cmp = *this <=> o;
699 return cmp !=
decltype(cmp)::equivalent;
701 template<
typename Other>
703 auto cmp = *this <=> o;
704 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::less;
706 template<
typename Other>
708 auto cmp = *this <=> o;
709 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::greater;
711 template<
typename Other>
713 auto cmp = *this <=> o;
714 return cmp ==
decltype(cmp)::less;
716 template<
typename Other>
718 auto cmp = *this <=> o;
719 return cmp ==
decltype(cmp)::greater;
729 return {Calendar::from_moment(
dateTime.to_moment().add_days(days))};
734 return {Calendar::from_moment(
dateTime.to_moment().sub_days(days))};
738 template<
typename Other>
741 return dateTime.to_moment().day_difference(om.dateTime.to_moment());
746 return {Calendar::from_moment(
758 return {Calendar::from_moment(
782 return {Calendar::from_moment(
788 return {Calendar::from_moment(
807 template<
typename Other>
810 const auto moment =
dateTime.to_moment();
815 return fixedRes.
error();
818 auto fixedDates = fixedRes.
value();
819 mtdefer { fixedDates.deinit(alloc); };
821 if (
const auto r = res.
init(alloc, fixedDates.size()); r.is_error()) {
825 auto iter = fixedDates.iter();
827 while (
iter.next().copy_if_present(cur)) {
851 return {Calendar::from_moment(
876 return {Calendar::from_moment(
911 template<
typename Calendar>
926 nz.offsetVal.hours = std::max<i8>(-23, std::min<i8>(23,
zone.offsetVal.hours));
927 nz.offsetVal.minutes = std::max<i8>(-60, std::min<i8>(60,
zone.offsetVal.minutes));
928 nz.offsetVal.seconds = std::max<i8>(-60, std::min<i8>(60,
zone.offsetVal.seconds));
936 template<
typename Other>
972 const auto utc =
to_utc();
973 auto nano =
static_cast<i64>(
static_cast<NanoSeconds>(utc.time_segments()).nano) + tz.offset_in_nanoseconds();
1000 template<
typename Other>
1002 const auto utc =
to_utc();
1003 const auto outc = o.
to_utc();
1004 return utc.dateTime <=> outc.dateTime;
1007 template<
typename Other>
1009 auto cmp = *this <=> o;
1010 return cmp ==
decltype(cmp)::equivalent;
1012 template<
typename Other>
1014 auto cmp = *this <=> o;
1015 return cmp !=
decltype(cmp)::equivalent;
1017 template<
typename Other>
1019 auto cmp = *this <=> o;
1020 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::less;
1022 template<
typename Other>
1024 auto cmp = *this <=> o;
1025 return cmp ==
decltype(cmp)::equivalent || cmp ==
decltype(cmp)::greater;
1027 template<
typename Other>
1029 auto cmp = *this <=> o;
1030 return cmp ==
decltype(cmp)::less;
1032 template<
typename Other>
1034 auto cmp = *this <=> o;
1035 return cmp ==
decltype(cmp)::greater;
1048 template<
typename Other>
1108 template<
typename Other>
1112 alloc,
static_cast<CalDateTime<Fixed>>(end).cal.to_fixed(), pthMoment, cDayCycle, delta);
1117 auto dates = pos.
value();
1118 mtdefer { dates.deinit(alloc); };
1120 if (
const auto r = res.
init(alloc, dates.size()); r.is_error()) {
1124 auto iter = dates.iter();
1126 while (
iter.next().copy_if_present(cur)) {
1148 return {
dateTime.kth_day_of_m_cycle_on_or_before(k, m, offset),
zone};
1159 return {
dateTime.kth_day_of_m_cycle_before(k, m, offset),
zone};
1170 return {
dateTime.kth_day_of_m_cycle_on_or_after(k, m, offset),
zone};
1181 return {
dateTime.kth_day_of_m_cycle_after(k, m, offset),
zone};
1192 return {
dateTime.kth_day_of_m_cycle_nearest(k, m, offset),
zone};
1196 static_assert(IsTimeCalendarSystem<Moment>);
1197 static_assert(IsDayCalendarSystem<Fixed>);
1204 template<
typename DateType>
static bool is_valid(const YearBase year)
auto operator!=(const AnnoDominiYear &o) const -> bool
auto operator<(const AnnoDominiYear &o) const -> bool
auto operator<=(const AnnoDominiYear &o) const -> bool
AnnoDominiYear operator+(YearBase years) const
auto operator>=(const AnnoDominiYear &o) const -> bool
AnnoDominiYear operator-(YearBase years) const
auto operator<=>(const AnnoDominiYear &o) const -> std::strong_ordering
auto operator==(const AnnoDominiYear &o) const -> bool
YearBase difference(AnnoDominiYear o) const
AnnoDominiYear(const YearBase year)
auto operator>(const AnnoDominiYear &o) const -> bool
auto operator!=(const AstronomicalYear &o) const -> bool
auto operator>(const AstronomicalYear &o) const -> bool
AstronomicalYear(const YearBase year)
AstronomicalYear()=default
AstronomicalYear operator+(YearBase years) const
auto operator==(const AstronomicalYear &o) const -> bool
YearBase difference(AstronomicalYear o) const
auto operator>=(const AstronomicalYear &o) const -> bool
auto operator<=>(const AstronomicalYear &o) const -> std::strong_ordering
AstronomicalYear operator-(YearBase years) const
static bool is_valid(const YearBase year)
auto operator<=(const AstronomicalYear &o) const -> bool
auto operator<(const AstronomicalYear &o) const -> bool
constexpr i64 NANOS_PER_DAY
Number of nanoseconds per day.
i32 YearBase
Year base type.
DayOfWeek
Enum class for the day of week.
constexpr auto nullopt
Placeholder value for an empty Optional.
AllocationError
Error indicating failed allocation.
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...
#define mtdefer
Defer statement that will mtdefer execution until the scope is left, at which point the code will run...
constexpr R floor(T num) noexcept
Floors a number with support for constexpr and fast runtime compilation.
Success< void > success()
Creates a successful void Result object.
constexpr bool is_initable
Checks if a type has an init with the param types.
uint64_t u64
Alias for 64-bit unsigned ints.
int32_t i32
Alias for 32-bit ints.
int64_t i64
Alias for 64-bit ints.
double f64
Alias for 64-bit floats.
Namespace for calendaring systems.
Generic iterator defaults built on common contracts Does not guarantee performance of iterators Actua...
Represents a memory allocator Exact behavior depends on the underlying VTable used Should use the a_*...
Array list is a growable, dynamic array with elements inside Elements are stored in an array,...
Result< void, AllocationError > init(Allocator &alloc, size_t initCapacity=10) noexcept
Initializes an empty ArrayList with an initial capacity.
Result< void, AllocationError > push(Allocator &alloc, const Slice< std::add_const_t< T > > &elems) noexcept
Pushes a list of items onto an array list.
Represents a value that may or may not exist (an "Optional" value) Similar concept to std::optional,...
Represents a Result that may have an error (error code) or a success value A type of "void" means the...
T value() const noexcept
Checks if is a successful Result (aka.
bool is_error() const noexcept
Checks if is an error Result.
ErrVal error() const noexcept
Returns the associated error Fails if there is no error;.
Wrapper for a date with a time component and timezone.
constexpr CalDateTimeZoned to_timezone(const TimeZone &tz) const noexcept
Convert to a specific timezone.
auto kth_day_of_m_cycle_before(i32 k, i32 m, i32 offset) const noexcept -> CalDateTimeZoned
Finds the kth day of the m-cycle that occurs before the current date.
constexpr CalDateTimeZoned sub_days(const i32 days) const
Subtracts n days from a date.
auto kth_day_of_m_cycle_nearest(i32 k, i32 m, i32 offset) const noexcept -> CalDateTimeZoned
Finds the kth day of the m-cycle that occurs nearest the current date.
constexpr auto operator==(const CalDateTimeZoned< Other > &o) const -> bool
constexpr auto operator>(const CalDateTimeZoned< Other > &o) const -> bool
constexpr CalDateTimeZoned day_of_week_before(const DayOfWeek k) const
Gets the day of week before current date.
auto positions_in_range(Allocator &alloc, const CalDateTime< Other > &end, i32 pthMoment, i32 cDayCycle, i32 delta) const -> Result< ArrayList< CalDateTimeZoned >, AllocationError >
Return the cyclic positions in the range of the current date to the end date (exclusive) Used to coll...
constexpr CalDateTimeZoned nearest_valid() const
Moves the date to the nearest valid date.
calendars::systems::Gregorian CalendarSystem
constexpr CalDateTimeZoned day_of_week_after(const DayOfWeek k) const
Gets the day of week after the current date.
constexpr CalDateTimeZoned to_utc() const noexcept
Convert to UTC timezone.
constexpr i32 day_difference(const CalDateTimeZoned< Other > &other) const
Difference between two dates in days.
constexpr CalDateTimeZoned nth_week_day(const i32 n, const DayOfWeek k) const
Gets the nth day of week.
constexpr CalDateTimeZoned day_of_week_on_or_before(const DayOfWeek k) const
Gets the day of week on or before the current date.
CalDateTime< calendars::systems::Gregorian > dateTime
auto kth_day_of_m_cycle_on_or_after(i32 k, i32 m, i32 offset) const noexcept -> CalDateTimeZoned
Finds the kth day of the m-cycle that occurs on or after the current date.
constexpr Segments time_segments() const noexcept
constexpr CalDateTimeZoned day_of_week_on_or_after(const DayOfWeek k) const
Gets the day of week on or after the current date.
constexpr CalDateTimeZoned add_days(const i32 days) const
Adds n days to a date.
auto kth_day_of_m_cycle_after(i32 k, i32 m, i32 offset) const noexcept -> CalDateTimeZoned
Finds the kth day of the m-cycle that occurs after the current date.
constexpr bool is_valid() const
Checks that a date is valid.
constexpr CalDateTimeZoned first_week_day(const DayOfWeek k) const
Gets the first week day in a month (assuming current date is the start of the month)
constexpr auto operator>=(const CalDateTimeZoned< Other > &o) const -> bool
constexpr CalDateTimeZoned day_of_week_nearest(const DayOfWeek k) const
Gets the day of week nearest to the current date.
constexpr auto operator<=(const CalDateTimeZoned< Other > &o) const -> bool
constexpr DayOfWeek day_of_week() const
Gets the day of week for a date.
constexpr auto operator<(const CalDateTimeZoned< Other > &o) const -> bool
constexpr auto operator!=(const CalDateTimeZoned< Other > &o) const -> bool
auto kth_day_of_m_cycle_on_or_before(i32 k, i32 m, i32 offset) const noexcept -> CalDateTimeZoned
Finds the kth day of the m-cycle that occurs on or before the current date.
i32 day_of_m_cycle(i32 m, i32 offset) const
Gets which day the current date occurs in an m-length ("month") cycle.
constexpr std::partial_ordering operator<=>(const CalDateTimeZoned< Other > &o) const
constexpr CalDateTimeZoned last_week_day(const DayOfWeek k) const
Gets the last week day in a month (assuming current date is the end of the month)
constexpr DayOfWeek day_of_week() const
Gets the day of week for a date.
constexpr auto operator>(const CalDateTime< Other > &o) const -> bool
i32 day_of_m_cycle(i32 m, i32 offset) const
Gets which day the current date occurs in an m-length ("month") cycle.
auto kth_day_of_m_cycle_on_or_after(i32 k, i32 m, i32 offset) const noexcept -> CalDateTime
Finds the kth day of the m-cycle that occurs on or after the current date.
constexpr CalDateTime day_of_week_before(const DayOfWeek k) const
Gets the day of week before current date.
auto kth_day_of_m_cycle_nearest(i32 k, i32 m, i32 offset) const noexcept -> CalDateTime
Finds the kth day of the m-cycle that occurs nearest the current date.
auto kth_day_of_m_cycle_before(i32 k, i32 m, i32 offset) const noexcept -> CalDateTime
Finds the kth day of the m-cycle that occurs before the current date.
constexpr i32 day_difference(const CalDateTime< Other > &other) const
Difference between two dates in days.
constexpr CalDateTime sub_days(const i32 days) const
Subtracts n days from a date.
constexpr std::partial_ordering operator<=>(const CalDateTime< Other > &o) const
constexpr bool is_valid() const
Checks that a date is valid.
constexpr CalDateTime day_of_week_on_or_after(const DayOfWeek k) const
Gets the day of week on or after the current date.
constexpr auto operator<(const CalDateTime< Other > &o) const -> bool
constexpr auto operator<=(const CalDateTime< Other > &o) const -> bool
constexpr CalDateTime nearest_valid() const
Moves the date to the nearest valid date.
constexpr auto operator>=(const CalDateTime< Other > &o) const -> bool
auto positions_in_range(Allocator &alloc, const CalDateTime< Other > &end, i32 pthMoment, i32 cDayCycle, i32 delta) const -> Result< ArrayList< CalDateTime >, AllocationError >
Return the cyclic positions in the range of the current date to the end date (exclusive) Used to coll...
auto kth_day_of_m_cycle_after(i32 k, i32 m, i32 offset) const noexcept -> CalDateTime
Finds the kth day of the m-cycle that occurs after the current date.
constexpr CalDateTime day_of_week_nearest(const DayOfWeek k) const
Gets the day of week nearest to the current date.
constexpr CalDateTime nth_week_day(const i32 n, const DayOfWeek k) const
Gets the nth day of week.
constexpr CalDateTime first_week_day(const DayOfWeek k) const
Gets the first week day in a month (assuming current date is the start of the month)
constexpr CalDateTime day_of_week_after(const DayOfWeek k) const
Gets the day of week after the current date.
constexpr auto operator==(const CalDateTime< Other > &o) const -> bool
constexpr CalDateTime add_days(const i32 days) const
Adds n days to a date.
auto kth_day_of_m_cycle_on_or_before(i32 k, i32 m, i32 offset) const noexcept -> CalDateTime
Finds the kth day of the m-cycle that occurs on or before the current date.
constexpr auto operator!=(const CalDateTime< Other > &o) const -> bool
constexpr Segments time_segments() const
constexpr CalDateTime last_week_day(const DayOfWeek k) const
Gets the last week day in a month (assuming current date is the end of the month)
constexpr CalDateTime day_of_week_on_or_before(const DayOfWeek k) const
Gets the day of week on or before the current date.
Wrapper for a date with a time component.
Represents a date without a time component.
auto positions_in_range(Allocator &alloc, const CalDate< Other > &end, i32 pthMoment, i32 cDayCycle, i32 delta) const -> Result< ArrayList< CalDate >, AllocationError >
Return the cyclic positions in the range of the current date to the end date (exclusive) Used to coll...
constexpr CalDate first_week_day(const DayOfWeek k) const
Gets the first week day in a month (assuming current date is the start of the month)
CalDate(const Calendar &c)
constexpr CalDate day_of_week_nearest(const DayOfWeek k) const
Gets the day of week nearest to the current date.
constexpr CalDate add_days(const i32 days) const
Adds days to a date.
constexpr auto operator<=(const CalDate< Other > &o) const -> bool
auto kth_day_of_m_cycle_before(i32 k, i32 m, i32 offset) const noexcept -> CalDate
Finds the kth day of the m-cycle that occurs before the current date.
CalDate(const CalDate &)=default
constexpr CalDate day_of_week_on_or_after(const DayOfWeek k) const
Gets the day of week on or after the current date.
constexpr auto operator<=>(const CalDate< Other > &o) const
Compares dates between two different calendar systems.
constexpr auto operator<(const CalDate< Other > &o) const -> bool
constexpr auto operator>(const CalDate< Other > &o) const -> bool
auto kth_day_of_m_cycle_after(i32 k, i32 m, i32 offset) const noexcept -> CalDate
Finds the kth day of the m-cycle that occurs after the current date.
auto kth_day_of_m_cycle_on_or_after(i32 k, i32 m, i32 offset) const noexcept -> CalDate
Finds the kth day of the m-cycle that occurs on or after the current date.
auto kth_day_of_m_cycle_nearest(i32 k, i32 m, i32 offset) const noexcept -> CalDate
Finds the kth day of the m-cycle that occurs nearest the current date.
CalDate & operator=(const CalDate &)=default
constexpr CalDate nearest_valid() const
Moves the date to the nearest valid date.
constexpr auto operator==(const CalDate< Other > &o) const -> bool
CalDate & operator=(CalDate &&)=default
constexpr CalDate day_of_week_after(const DayOfWeek k) const
Gets the day of week after the current date.
static constexpr CalDate make(Args... args)
constexpr auto operator!=(const CalDate< Other > &o) const -> bool
constexpr CalDate nth_week_day(const i32 n, const DayOfWeek k) const
Gets the nth day of week.
constexpr bool is_valid() const
Checks that a date is valid.
i32 day_of_m_cycle(i32 m, i32 offset) const
Gets which day the current date occurs in an m-length ("month") cycle.
constexpr DayOfWeek day_of_week() const
Gets the day of week for a calendar.
auto kth_day_of_m_cycle_on_or_before(i32 k, i32 m, i32 offset) const noexcept -> CalDate
Finds the kth day of the m-cycle that occurs on or before the current date.
constexpr CalDate day_of_week_on_or_before(const DayOfWeek k) const
Gets the day of week on or before the current date.
constexpr CalDate & init(Args... args)
CalDate(CalDate &&)=default
constexpr CalDate day_of_week_before(const DayOfWeek k) const
Gets the day of week before current date.
constexpr auto operator>=(const CalDate< Other > &o) const -> bool
constexpr CalDate last_week_day(const DayOfWeek k) const
Gets the last week day in a month (assuming current date is the end of the month)
constexpr i32 day_difference(const CalDate< Other > &other) const
Gets the difference in days between dates.
constexpr CalDate sub_days(const i32 days) const
Subtracts days from a date.
Base calendar system tracking the number of days since its epoch.
auto positions_in_range(Allocator &alloc, const Fixed &end, i32 pthMoment, i32 cDayCycle, i32 delta) const -> Result< mtcore::ArrayList< Fixed >, AllocationError >
Return the cyclic positions in the range of the current date to the end date (exclusive) Used to coll...
constexpr i32 day_of_m_cycle(i32 m, i32 offset) const
Gets which day the current date occurs in an m-length ("month") cycle.
constexpr DayOfWeek day_of_week() const
Gets the day of week for a date.
Base calendar system tracking the number of days (and fraction of days) since its epoch.
static constexpr Moment reconstruct(const Fixed &f, const Moment &m)
Reconstructs a moment from a fixed date and the time portion of a moment.
static constexpr Fixed moment_to_fixed(const Moment &m)
Converts a moment to fixed date (drops time)
Optional< DateType > next()
Range of dates with start and end.
auto iter() const
Iterator.
auto size() const
Size of range.
Represents time in segments (hour, minute, etc.).