MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::calendars::CalDateTime< Calendar > Struct Template Reference

#include <core.hpp>

Inheritance diagram for mtcore::calendars::CalDateTime< Calendar >:
Collaboration diagram for mtcore::calendars::CalDateTime< Calendar >:

Public Types

using CalendarSystem = Calendar
 

Public Member Functions

constexpr Segments time_segments () const
 
constexpr operator CalDate< Calendar > () const noexcept
 
constexpr bool is_valid () const
 Checks that a date is valid.
 
constexpr CalDateTime nearest_valid () const
 Moves the date to the nearest valid date.
 
template<typename Other>
constexpr operator CalDateTime< Other > () const noexcept
 
template<IsTimeCalendarSystem Other>
constexpr std::partial_ordering operator<=> (const CalDateTime< Other > &o) const
 
template<IsDayCalendarSystem Other>
constexpr std::partial_ordering operator<=> (const CalDateTime< Other > &o) const
 
template<typename Other>
constexpr auto operator== (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator!= (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator<= (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator>= (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator< (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator> (const CalDateTime< Other > &o) const -> bool
 
constexpr DayOfWeek day_of_week () const
 Gets the day of week for a date.
 
constexpr CalDateTime add_days (const i32 days) const
 Adds n days to a date.
 
constexpr CalDateTime sub_days (const i32 days) const
 Subtracts n days from a date.
 
template<typename Other>
constexpr i32 day_difference (const CalDateTime< Other > &other) const
 Difference between two dates in days.
 
constexpr CalDateTime nth_week_day (const i32 n, const DayOfWeek k) const
 Gets the nth day of week.
 
constexpr CalDateTime day_of_week_before (const DayOfWeek k) const
 Gets the day of week before current date.
 
constexpr CalDateTime day_of_week_after (const DayOfWeek k) const
 Gets the day of week 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 day_of_week_on_or_before (const DayOfWeek k) const
 Gets the day of week on or before the current date.
 
constexpr CalDateTime day_of_week_on_or_after (const DayOfWeek k) const
 Gets the day of week on or after the current date.
 
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 last_week_day (const DayOfWeek k) const
 Gets the last week day in a month (assuming current date is the end of the month)
 
template<typename Other>
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 collect all occurrences of events (e.g.
 
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_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.
 
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.
 
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.
 
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.
 
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.
 
constexpr bool is_valid () const
 Checks that a date is valid.
 
constexpr CalDateTime nearest_valid () const
 Moves the date to the nearest valid date.
 
constexpr Segments time_segments () const
 
constexpr operator CalDate< Fixed > () const noexcept
 
template<typename Other>
constexpr operator CalDateTime< Other > () const noexcept
 
template<IsDayCalendarSystem Other>
constexpr std::partial_ordering operator<=> (const CalDateTime< Other > &o) const
 
template<IsTimeCalendarSystem Other>
constexpr std::partial_ordering operator<=> (const CalDateTime< Other > &o) const
 
template<typename Other>
constexpr auto operator== (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator!= (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator<= (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator>= (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator< (const CalDateTime< Other > &o) const -> bool
 
template<typename Other>
constexpr auto operator> (const CalDateTime< Other > &o) const -> bool
 
constexpr DayOfWeek day_of_week () const
 Gets the day of week for a date.
 
constexpr CalDateTime add_days (const i32 days) const
 Adds n days to a date.
 
constexpr CalDateTime sub_days (const i32 days) const
 Subtracts n days from a date.
 
template<typename Other>
constexpr i32 day_difference (const CalDateTime< Other > &other) const
 Difference between two dates in days.
 
constexpr CalDateTime nth_week_day (const i32 n, const DayOfWeek k) const
 Gets the nth day of week.
 
constexpr CalDateTime day_of_week_before (const DayOfWeek k) const
 Gets the day of week before current date.
 
constexpr CalDateTime day_of_week_after (const DayOfWeek k) const
 Gets the day of week 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 day_of_week_on_or_before (const DayOfWeek k) const
 Gets the day of week on or before the current date.
 
constexpr CalDateTime day_of_week_on_or_after (const DayOfWeek k) const
 Gets the day of week on or after the current date.
 
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 last_week_day (const DayOfWeek k) const
 Gets the last week day in a month (assuming current date is the end of the month)
 
template<typename Other>
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 collect all occurrences of events (e.g.
 
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_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.
 
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.
 
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.
 
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.
 
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.
 

Public Attributes

Calendar cal
 
Segments time = {}
 
Calendar dateTime
 

Detailed Description

template<IsDayCalendarSystem Calendar>
struct mtcore::calendars::CalDateTime< Calendar >

Definition at line 372 of file calendars/mtcore_calendars/core.hpp.

Member Typedef Documentation

◆ CalendarSystem

template<IsDayCalendarSystem Calendar>
using mtcore::calendars::CalDateTime< Calendar >::CalendarSystem = Calendar

Definition at line 373 of file calendars/mtcore_calendars/core.hpp.

Member Function Documentation

◆ add_days() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::add_days ( const i32 days) const
inlinenodiscardconstexpr

Adds n days to a date.

Definition at line 478 of file calendars/mtcore_calendars/core.hpp.

478 {
479 return {Calendar::from_fixed(cal.to_fixed().add_days(days))};
480 }
Wrapper for a date with a time component.

◆ add_days() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::add_days ( const i32 days) const
inlinenodiscardconstexpr

Adds n days to a date.

Definition at line 728 of file calendars/mtcore_calendars/core.hpp.

◆ day_difference() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
i32 mtcore::calendars::CalDateTime< Calendar >::day_difference ( const CalDateTime< Other > & other) const
inlinenodiscardconstexpr

Difference between two dates in days.

Definition at line 489 of file calendars/mtcore_calendars/core.hpp.

489 {
490 const auto om = static_cast<CalDateTime<Calendar>>(other);
491 return cal.to_fixed().day_difference(om.cal.to_fixed());
492 }

◆ day_difference() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
i32 mtcore::calendars::CalDateTime< Calendar >::day_difference ( const CalDateTime< Other > & other) const
inlinenodiscardconstexpr

Difference between two dates in days.

Definition at line 739 of file calendars/mtcore_calendars/core.hpp.

739 {
740 const auto om = static_cast<CalDateTime<Calendar>>(other);
741 return dateTime.to_moment().day_difference(om.dateTime.to_moment());
742 }

◆ day_of_m_cycle() [1/2]

template<IsDayCalendarSystem Calendar>
i32 mtcore::calendars::CalDateTime< Calendar >::day_of_m_cycle ( i32 m,
i32 offset ) const
inlinenodiscard

Gets which day the current date occurs in an m-length ("month") cycle.

Parameters
mLength of cycle
offsetOffset for start of cycle

Definition at line 579 of file calendars/mtcore_calendars/core.hpp.

579{ return cal.to_fixed().day_of_m_cycle(m, offset); }

◆ day_of_m_cycle() [2/2]

template<IsDayCalendarSystem Calendar>
i32 mtcore::calendars::CalDateTime< Calendar >::day_of_m_cycle ( i32 m,
i32 offset ) const
inlinenodiscard

Gets which day the current date occurs in an m-length ("month") cycle.

Parameters
mLength of cycle
offsetOffset for start of cycle

Definition at line 839 of file calendars/mtcore_calendars/core.hpp.

839 {
841 }
constexpr i32 day_of_m_cycle(i32 m, i32 offset) const
Gets which day the current date occurs in an m-length ("month") cycle.
Definition fixed.hpp:185
static constexpr Fixed moment_to_fixed(const Moment &m)
Converts a moment to fixed date (drops time)
Definition fixed.hpp:281
Here is the call graph for this function:

◆ day_of_week() [1/2]

template<IsDayCalendarSystem Calendar>
DayOfWeek mtcore::calendars::CalDateTime< Calendar >::day_of_week ( ) const
inlinenodiscardconstexpr

Gets the day of week for a date.

Definition at line 475 of file calendars/mtcore_calendars/core.hpp.

475{ return cal.to_fixed().day_of_week(); }

◆ day_of_week() [2/2]

template<IsDayCalendarSystem Calendar>
DayOfWeek mtcore::calendars::CalDateTime< Calendar >::day_of_week ( ) const
inlinenodiscardconstexpr

Gets the day of week for a date.

Definition at line 723 of file calendars/mtcore_calendars/core.hpp.

723 {
724 return Moment::moment_to_fixed(dateTime.to_moment()).day_of_week();
725 }
constexpr DayOfWeek day_of_week() const
Gets the day of week for a date.
Definition fixed.hpp:83
Here is the call graph for this function:

◆ day_of_week_after() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_after ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week after the current date.

Definition at line 505 of file calendars/mtcore_calendars/core.hpp.

505 {
506 return {Calendar::from_fixed(cal.to_fixed().day_of_week_after(k))};
507 }

◆ day_of_week_after() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_after ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week after the current date.

Definition at line 757 of file calendars/mtcore_calendars/core.hpp.

757 {
758 return {Calendar::from_moment(
759 Moment::reconstruct(Moment::moment_to_fixed(dateTime.to_moment()).day_of_week_after(k), dateTime.to_moment()))};
760 }
Here is the call graph for this function:

◆ day_of_week_before() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_before ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week before current date.

Definition at line 500 of file calendars/mtcore_calendars/core.hpp.

500 {
501 return {Calendar::from_fixed(cal.to_fixed().day_of_week_before(k))};
502 }

◆ day_of_week_before() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_before ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week before current date.

Definition at line 751 of file calendars/mtcore_calendars/core.hpp.

751 {
753 Moment::moment_to_fixed(dateTime.to_moment()).day_of_week_before(k), dateTime.to_moment()))};
754 }
Here is the call graph for this function:

◆ day_of_week_nearest() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_nearest ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week nearest to the current date.

Definition at line 510 of file calendars/mtcore_calendars/core.hpp.

510 {
511 return {Calendar::from_fixed(cal.to_fixed().day_of_week_nearest(k))};
512 }

◆ day_of_week_nearest() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_nearest ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week nearest to the current date.

Definition at line 763 of file calendars/mtcore_calendars/core.hpp.

763 {
765 Moment::moment_to_fixed(dateTime.to_moment()).day_of_week_nearest(k), dateTime.to_moment()))};
766 }
Here is the call graph for this function:

◆ day_of_week_on_or_after() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_on_or_after ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week on or after the current date.

Definition at line 520 of file calendars/mtcore_calendars/core.hpp.

520 {
521 return {Calendar::from_fixed(cal.to_fixed().day_of_week_on_or_after(k))};
522 }

◆ day_of_week_on_or_after() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_on_or_after ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week on or after the current date.

Definition at line 775 of file calendars/mtcore_calendars/core.hpp.

775 {
777 Moment::moment_to_fixed(dateTime.to_moment()).day_of_week_on_or_after(k), dateTime.to_moment()))};
778 }
Here is the call graph for this function:

◆ day_of_week_on_or_before() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_on_or_before ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week on or before the current date.

Definition at line 515 of file calendars/mtcore_calendars/core.hpp.

515 {
516 return {Calendar::from_fixed(cal.to_fixed().day_of_week_on_or_before(k))};
517 }

◆ day_of_week_on_or_before() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::day_of_week_on_or_before ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the day of week on or before the current date.

Definition at line 769 of file calendars/mtcore_calendars/core.hpp.

769 {
771 Moment::moment_to_fixed(dateTime.to_moment()).day_of_week_on_or_before(k), dateTime.to_moment()))};
772 }
Here is the call graph for this function:

◆ first_week_day() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::first_week_day ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the first week day in a month (assuming current date is the start of the month)

Definition at line 525 of file calendars/mtcore_calendars/core.hpp.

525 {
526 return {Calendar::from_fixed(cal.to_fixed().first_week_day(k))};
527 }

◆ first_week_day() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::first_week_day ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the first week day in a month (assuming current date is the start of the month)

Definition at line 781 of file calendars/mtcore_calendars/core.hpp.

781 {
782 return {Calendar::from_moment(
783 Moment::reconstruct(Moment::moment_to_fixed(dateTime.to_moment()).first_week_day(k), dateTime.to_moment()))};
784 }
Here is the call graph for this function:

◆ is_valid() [1/2]

template<IsDayCalendarSystem Calendar>
bool mtcore::calendars::CalDateTime< Calendar >::is_valid ( ) const
inlinenodiscardconstexpr

Checks that a date is valid.

Definition at line 382 of file calendars/mtcore_calendars/core.hpp.

382{ return *this == nearest_valid(); }
constexpr CalDateTime nearest_valid() const
Moves the date to the nearest valid date.
Here is the call graph for this function:

◆ is_valid() [2/2]

template<IsDayCalendarSystem Calendar>
bool mtcore::calendars::CalDateTime< Calendar >::is_valid ( ) const
inlinenodiscardconstexpr

Checks that a date is valid.

Definition at line 642 of file calendars/mtcore_calendars/core.hpp.

642{ return *this == nearest_valid(); }
Here is the call graph for this function:

◆ kth_day_of_m_cycle_after() [1/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_after ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs after the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 621 of file calendars/mtcore_calendars/core.hpp.

621 {
622 return {Calendar::from_fixed(cal.to_fixed().kth_day_of_m_cycle_after(k, m, offset)), time};
623 }

◆ kth_day_of_m_cycle_after() [2/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_after ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs after the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 888 of file calendars/mtcore_calendars/core.hpp.

888 {
890 Moment::moment_to_fixed(dateTime.to_moment()).kth_day_of_m_cycle_after(k, m, offset), dateTime.to_moment()))};
891 }
Here is the call graph for this function:

◆ kth_day_of_m_cycle_before() [1/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_before ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs before the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 599 of file calendars/mtcore_calendars/core.hpp.

599 {
600 return {Calendar::from_fixed(cal.to_fixed().kth_day_of_m_cycle_before(k, m, offset)), time};
601 }

◆ kth_day_of_m_cycle_before() [2/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_before ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs before the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 863 of file calendars/mtcore_calendars/core.hpp.

863 {
865 Moment::moment_to_fixed(dateTime.to_moment()).kth_day_of_m_cycle_before(k, m, offset), dateTime.to_moment()))};
866 }
Here is the call graph for this function:

◆ kth_day_of_m_cycle_nearest() [1/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_nearest ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs nearest the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 632 of file calendars/mtcore_calendars/core.hpp.

632 {
633 return {Calendar::from_fixed(cal.to_fixed().kth_day_of_m_cycle_nearest(k, m, offset)), time};
634 }

◆ kth_day_of_m_cycle_nearest() [2/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_nearest ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs nearest the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 900 of file calendars/mtcore_calendars/core.hpp.

900 {
902 Moment::moment_to_fixed(dateTime.to_moment()).kth_day_of_m_cycle_nearest(k, m, offset), dateTime.to_moment()))};
903 }
Here is the call graph for this function:

◆ kth_day_of_m_cycle_on_or_after() [1/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_on_or_after ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs on or after the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 610 of file calendars/mtcore_calendars/core.hpp.

610 {
611 return {Calendar::from_fixed(cal.to_fixed().kth_day_of_m_cycle_on_or_after(k, m, offset)), time};
612 }

◆ kth_day_of_m_cycle_on_or_after() [2/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_on_or_after ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs on or after the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 875 of file calendars/mtcore_calendars/core.hpp.

875 {
876 return {Calendar::from_moment(
877 Moment::reconstruct(Moment::moment_to_fixed(dateTime.to_moment()).kth_day_of_m_cycle_on_or_after(k, m, offset),
878 dateTime.to_moment()))};
879 }
Here is the call graph for this function:

◆ kth_day_of_m_cycle_on_or_before() [1/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_on_or_before ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs on or before the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 588 of file calendars/mtcore_calendars/core.hpp.

588 {
589 return {Calendar::from_fixed(cal.to_fixed().kth_day_of_m_cycle_on_or_before(k, m, offset)), time};
590 }

◆ kth_day_of_m_cycle_on_or_before() [2/2]

template<IsDayCalendarSystem Calendar>
auto mtcore::calendars::CalDateTime< Calendar >::kth_day_of_m_cycle_on_or_before ( i32 k,
i32 m,
i32 offset ) const -> CalDateTime
inlinenodiscardnoexcept

Finds the kth day of the m-cycle that occurs on or before the current date.

Parameters
kThe kth day of the m-cycle
mThe number of days in the m-cycle
offsetThe offset of the m-cycle
Returns
A date with the result

Definition at line 850 of file calendars/mtcore_calendars/core.hpp.

850 {
851 return {Calendar::from_moment(
852 Moment::reconstruct(Moment::moment_to_fixed(dateTime.to_moment()).kth_day_of_m_cycle_on_or_before(k, m, offset),
853 dateTime.to_moment()))};
854 }
Here is the call graph for this function:

◆ last_week_day() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::last_week_day ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the last week day in a month (assuming current date is the end of the month)

Definition at line 530 of file calendars/mtcore_calendars/core.hpp.

530 {
531 return {Calendar::from_fixed(cal.to_fixed().last_week_day(k))};
532 }

◆ last_week_day() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::last_week_day ( const DayOfWeek k) const
inlinenodiscardconstexpr

Gets the last week day in a month (assuming current date is the end of the month)

Definition at line 787 of file calendars/mtcore_calendars/core.hpp.

787 {
788 return {Calendar::from_moment(
789 Moment::reconstruct(Moment::moment_to_fixed(dateTime.to_moment()).last_week_day(k), dateTime.to_moment()))};
790 }
Here is the call graph for this function:

◆ nearest_valid() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::nearest_valid ( ) const
inlinenodiscardconstexpr

Moves the date to the nearest valid date.

Definition at line 385 of file calendars/mtcore_calendars/core.hpp.

385 {
386 auto nearestDate = cal.to_fixed().day;
387 auto frac = time.to_fraction_unchecked();
388 if (frac < 0) {
390 }
391 else if (frac > 1) {
393 }
396 }
constexpr R floor(T num) noexcept
Floors a number with support for constexpr and fast runtime compilation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nearest_valid() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::nearest_valid ( ) const
inlinenodiscardconstexpr

Moves the date to the nearest valid date.

Definition at line 645 of file calendars/mtcore_calendars/core.hpp.

645 {
646 return CalDateTime{Calendar::from_moment(dateTime.to_moment())};
647 }

◆ nth_week_day() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::nth_week_day ( const i32 n,
const DayOfWeek k ) const
inlinenodiscardconstexpr

Gets the nth day of week.

Definition at line 495 of file calendars/mtcore_calendars/core.hpp.

495 {
496 return {Calendar::from_fixed(cal.to_fixed().nth_week_day(n, k))};
497 }

◆ nth_week_day() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::nth_week_day ( const i32 n,
const DayOfWeek k ) const
inlinenodiscardconstexpr

Gets the nth day of week.

Definition at line 745 of file calendars/mtcore_calendars/core.hpp.

745 {
746 return {Calendar::from_moment(
747 Moment::reconstruct(Moment::moment_to_fixed(dateTime.to_moment()).nth_week_day(n, k), dateTime.to_moment()))};
748 }
Here is the call graph for this function:

◆ operator CalDate< Calendar >()

template<IsDayCalendarSystem Calendar>
mtcore::calendars::CalDateTime< Calendar >::operator CalDate< Calendar > ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 379 of file calendars/mtcore_calendars/core.hpp.

379{ return CalDate<Calendar>{cal}; }

◆ operator CalDate< Fixed >()

template<IsDayCalendarSystem Calendar>
mtcore::calendars::CalDateTime< Calendar >::operator CalDate< Fixed > ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 655 of file calendars/mtcore_calendars/core.hpp.

655 {
656 return CalDate<Fixed>{{math::floor(dateTime.dayAndTime)}};
657 }
Here is the call graph for this function:

◆ operator CalDateTime< Other >() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
mtcore::calendars::CalDateTime< Calendar >::operator CalDateTime< Other > ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 399 of file calendars/mtcore_calendars/core.hpp.

399 {
400 if constexpr (IsDayCalendarSystem<Other>) {
401 return {Other::from_fixed(cal.to_fixed()), time};
402 }
403 else {
404 Moment t = {static_cast<f64>(cal.to_fixed().day) + time.to_fraction_unchecked()};
405 return {Other::from_moment(t)};
406 }
407 }

◆ operator CalDateTime< Other >() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
mtcore::calendars::CalDateTime< Calendar >::operator CalDateTime< Other > ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 660 of file calendars/mtcore_calendars/core.hpp.

660 {
661 if constexpr (IsTimeCalendarSystem<Other>) {
662 return {Other::from_moment(dateTime.to_moment()), time};
663 }
664 else {
665 const auto m = dateTime.to_moment();
666 const i32 day = math::floor(dateTime.dayAndTime);
667 const auto dayFrac = DayFraction{m.dayAndTime - math::floor(dateTime.dayAndTime)};
668 return {
670 static_cast<Segments>(dayFrac),
671 };
672 }
673 }
Here is the call graph for this function:

◆ operator!=() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator!= ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 449 of file calendars/mtcore_calendars/core.hpp.

449 {
450 auto cmp = *this <=> o;
451 return cmp != decltype(cmp)::equivalent;
452 }

◆ operator!=() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator!= ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 697 of file calendars/mtcore_calendars/core.hpp.

697 {
698 auto cmp = *this <=> o;
699 return cmp != decltype(cmp)::equivalent;
700 }

◆ operator<() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator< ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 464 of file calendars/mtcore_calendars/core.hpp.

464 {
465 auto cmp = *this <=> o;
466 return cmp == decltype(cmp)::less;
467 }

◆ operator<() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator< ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 712 of file calendars/mtcore_calendars/core.hpp.

712 {
713 auto cmp = *this <=> o;
714 return cmp == decltype(cmp)::less;
715 }

◆ operator<=() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator<= ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 454 of file calendars/mtcore_calendars/core.hpp.

454 {
455 auto cmp = *this <=> o;
456 return cmp == decltype(cmp)::equivalent || cmp == decltype(cmp)::less;
457 }

◆ operator<=() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator<= ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 702 of file calendars/mtcore_calendars/core.hpp.

702 {
703 auto cmp = *this <=> o;
704 return cmp == decltype(cmp)::equivalent || cmp == decltype(cmp)::less;
705 }

◆ operator<=>() [1/4]

template<IsDayCalendarSystem Calendar>
template<IsTimeCalendarSystem Other>
std::partial_ordering mtcore::calendars::CalDateTime< Calendar >::operator<=> ( const CalDateTime< Other > & o) const
inlinenodiscardconstexpr

Definition at line 410 of file calendars/mtcore_calendars/core.hpp.

410 {
413 return cmp;
414 }
415 return time <=> o.time;
416 }
417 else {
418 if (const std::partial_ordering cmp = cal.to_moment() <=> o.cal.to_moment();
420 return cmp;
421 }
422 return time <=> o.time;
423 }
424 }

◆ operator<=>() [2/4]

template<IsDayCalendarSystem Calendar>
template<IsDayCalendarSystem Other>
std::partial_ordering mtcore::calendars::CalDateTime< Calendar >::operator<=> ( const CalDateTime< Other > & o) const
inlinenodiscardconstexpr

Definition at line 427 of file calendars/mtcore_calendars/core.hpp.

427 {
430 return cmp;
431 }
432 return time <=> o.time;
433 }
434 else {
435 if (const std::strong_ordering cmp = cal.to_fixed() <=> o.cal.to_fixed();
437 return cmp;
438 }
439 return time <=> o.time;
440 }
441 }

◆ operator<=>() [3/4]

template<IsDayCalendarSystem Calendar>
template<IsDayCalendarSystem Other>
std::partial_ordering mtcore::calendars::CalDateTime< Calendar >::operator<=> ( const CalDateTime< Other > & o) const
inlinenodiscardconstexpr

Definition at line 676 of file calendars/mtcore_calendars/core.hpp.

676 {
677 const auto om = static_cast<CalDateTime<Calendar>>(o);
678 return *this <=> om;
679 }

◆ operator<=>() [4/4]

template<IsDayCalendarSystem Calendar>
template<IsTimeCalendarSystem Other>
std::partial_ordering mtcore::calendars::CalDateTime< Calendar >::operator<=> ( const CalDateTime< Other > & o) const
inlinenodiscardconstexpr

Definition at line 682 of file calendars/mtcore_calendars/core.hpp.

682 {
684 return dateTime <=> o.dateTime;
685 }
686 else {
687 return dateTime.to_moment() <=> o.dateTime.to_moment();
688 }
689 }

◆ operator==() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator== ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 444 of file calendars/mtcore_calendars/core.hpp.

444 {
445 auto cmp = *this <=> o;
446 return cmp == decltype(cmp)::equivalent;
447 }

◆ operator==() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator== ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 692 of file calendars/mtcore_calendars/core.hpp.

692 {
693 auto cmp = *this <=> o;
694 return cmp == decltype(cmp)::equivalent;
695 }

◆ operator>() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator> ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 469 of file calendars/mtcore_calendars/core.hpp.

469 {
470 auto cmp = *this <=> o;
471 return cmp == decltype(cmp)::greater;
472 }

◆ operator>() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator> ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 717 of file calendars/mtcore_calendars/core.hpp.

717 {
718 auto cmp = *this <=> o;
719 return cmp == decltype(cmp)::greater;
720 }

◆ operator>=() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator>= ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 459 of file calendars/mtcore_calendars/core.hpp.

459 {
460 auto cmp = *this <=> o;
461 return cmp == decltype(cmp)::equivalent || cmp == decltype(cmp)::greater;
462 }

◆ operator>=() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::operator>= ( const CalDateTime< Other > & o) const -> bool
inlinenodiscardconstexpr

Definition at line 707 of file calendars/mtcore_calendars/core.hpp.

707 {
708 auto cmp = *this <=> o;
709 return cmp == decltype(cmp)::equivalent || cmp == decltype(cmp)::greater;
710 }

◆ positions_in_range() [1/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::positions_in_range ( Allocator & alloc,
const CalDateTime< Other > & end,
i32 pthMoment,
i32 cDayCycle,
i32 delta ) const -> Result<ArrayList<CalDateTime>, AllocationError>
inlinenodiscard

Return the cyclic positions in the range of the current date to the end date (exclusive) Used to collect all occurrences of events (e.g.

holidays) in an interval of time (e.g. a Gregorian year)

Assumes $0 \le pthMoment \lt cDayCycle$

Parameters
allocAllocator to use
endEnd of the cyclic range
pthMomentStarting pth moment search. First result on or after a given moment of the pth moment (basically the cycle start)
cDayCycleThe number of days in the occurrence day cycle (basically the cycle length)
deltaCongruent modulo of cDayCycle to the position of RdDate{0} in the repeating cycle (basically the cycle modulo offset)
Returns

Definition at line 550 of file calendars/mtcore_calendars/core.hpp.

551 {
552 Result<ArrayList<Fixed>, AllocationError> fixedRes = cal.to_fixed().positions_in_range(
553 alloc, static_cast<CalDateTime<Fixed>>(end).cal.to_fixed(), pthMoment, cDayCycle, delta);
554 if (fixedRes.is_error()) {
555 return fixedRes.error();
556 }
557
558 auto fixedDates = fixedRes.value();
559 mtdefer { fixedDates.deinit(alloc); };
561 if (const auto r = res.init(alloc, fixedDates.size()); r.is_error()) {
562 return r.error();
563 }
564
565 auto iter = fixedDates.iter();
566 Fixed cur = {};
567 while (iter.next().copy_if_present(cur)) {
568 ensure(res.push(CalDateTime{Calendar::from_fixed(cur), time}).is_success());
569 }
570
571 return success(res);
572 }
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...
Success< void > success()
Creates a successful void Result object.
Definition result.hpp:398
Here is the call graph for this function:

◆ positions_in_range() [2/2]

template<IsDayCalendarSystem Calendar>
template<typename Other>
auto mtcore::calendars::CalDateTime< Calendar >::positions_in_range ( Allocator & alloc,
const CalDateTime< Other > & end,
i32 pthMoment,
i32 cDayCycle,
i32 delta ) const -> Result<ArrayList<CalDateTime>, AllocationError>
inlinenodiscard

Return the cyclic positions in the range of the current date to the end date (exclusive) Used to collect all occurrences of events (e.g.

holidays) in an interval of time (e.g. a Gregorian year)

Assumes $0 \le pthMoment \lt cDayCycle$

Parameters
allocAllocator to use
endEnd of the cyclic range
pthMomentStarting pth moment search. First result on or after a given moment of the pth moment (basically the cycle start)
cDayCycleThe number of days in the occurrence day cycle (basically the cycle length)
deltaCongruent modulo of cDayCycle to the position of RdDate{0} in the repeating cycle (basically the cycle modulo offset)
Returns

Definition at line 808 of file calendars/mtcore_calendars/core.hpp.

809 {
810 const auto moment = dateTime.to_moment();
811
813 alloc, static_cast<CalDateTime<Fixed>>(end).cal.to_fixed(), pthMoment, cDayCycle, delta);
814 if (fixedRes.is_error()) {
815 return fixedRes.error();
816 }
817
818 auto fixedDates = fixedRes.value();
819 mtdefer { fixedDates.deinit(alloc); };
821 if (const auto r = res.init(alloc, fixedDates.size()); r.is_error()) {
822 return r.error();
823 }
824
825 auto iter = fixedDates.iter();
826 Fixed cur = {};
827 while (iter.next().copy_if_present(cur)) {
828 ensure(res.push(CalDateTime{Calendar::from_moment(Moment::reconstruct(cur, moment))}).is_success());
829 }
830
831 return success(res);
832 }
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...
Definition fixed.hpp:161
Here is the call graph for this function:

◆ sub_days() [1/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::sub_days ( const i32 days) const
inlinenodiscardconstexpr

Subtracts n days from a date.

Definition at line 483 of file calendars/mtcore_calendars/core.hpp.

483 {
484 return {Calendar::from_fixed(cal.to_fixed().sub_days(days))};
485 }

◆ sub_days() [2/2]

template<IsDayCalendarSystem Calendar>
CalDateTime mtcore::calendars::CalDateTime< Calendar >::sub_days ( const i32 days) const
inlinenodiscardconstexpr

Subtracts n days from a date.

Definition at line 733 of file calendars/mtcore_calendars/core.hpp.

733 {
734 return {Calendar::from_moment(dateTime.to_moment().sub_days(days))};
735 }

◆ time_segments() [1/2]

template<IsDayCalendarSystem Calendar>
Segments mtcore::calendars::CalDateTime< Calendar >::time_segments ( ) const
inlinenodiscardconstexpr

Definition at line 377 of file calendars/mtcore_calendars/core.hpp.

377{ return time; }

◆ time_segments() [2/2]

template<IsDayCalendarSystem Calendar>
Segments mtcore::calendars::CalDateTime< Calendar >::time_segments ( ) const
inlinenodiscardconstexpr

Definition at line 649 of file calendars/mtcore_calendars/core.hpp.

649 {
650 const auto m = dateTime.to_moment();
651 const auto df = DayFraction{m - math::floor(m)};
652 return static_cast<Segments>(df);
653 }
Here is the call graph for this function:

Member Data Documentation

◆ cal

template<IsDayCalendarSystem Calendar>
Calendar mtcore::calendars::CalDateTime< Calendar >::cal

Definition at line 374 of file calendars/mtcore_calendars/core.hpp.

◆ dateTime

template<IsDayCalendarSystem Calendar>
Calendar mtcore::calendars::CalDateTime< Calendar >::dateTime

Definition at line 639 of file calendars/mtcore_calendars/core.hpp.

◆ time

template<IsDayCalendarSystem Calendar>
Segments mtcore::calendars::CalDateTime< Calendar >::time = {}

Definition at line 375 of file calendars/mtcore_calendars/core.hpp.

375{};

The documentation for this struct was generated from the following file: