Comparison operators for underspecified cyclical time (mt_cyclical_free)
Source: R/compare.R
mt_cyclical_free-compare.RdUnderspecified cyclical time (see cyclical_time()) is a magnitude within
a cycle whose enclosing cycle is unknown (e.g. day_of_year(60), "day
60 of the year", with no year known) - modelled on mt_duration, not
mt_cyclical. Comparing two free values is therefore
mt_duration-compare's plain magnitude comparison, not
mt_cyclical-compare's interval/position reduction:
a == biff the two magnitudes are equal in their common chronona < b,a <= b,a > b,a >= bcompare the magnitudes directly
Both operands must share a cycle (a type-compatibility tag, not a unit -
see mt_cyclical-compare): comparing (say) a day-of-week-free against a
day-of-year-free is an error. Differing chronons within a shared cycle are
reconciled by scaling both magnitudes to their finest common chronon via
chronon_cardinality() - never chronon_divmod(), which would assert
that the stored number's position is measured relative to some specific
enclosing cycle, a claim that is false by construction for data
defined to carry no knowledge of which cycle it falls in.
Underspecified cyclical time can also be compared against located
mt_cyclical: the located side reduces to its position within the cycle via its own
existing, unchanged machinery (the same reduction format() and
mt_cyclical-compare use), and both sides are then compared as
magnitudes.
Positions are ordered linearly within one cycle (January < ... <
December, with no wrapping), which sort(), order(), min(), max()
and range() follow. Subtraction follows the same order: a - b between
free values of the same cycle is the duration between their positions,
so month_of_year(3) - month_of_year(1) is 2 months and
month_of_year(1) - month_of_year(3) is -2 months (see
mt_cyclical_free-arithmetic for the arithmetic rules).
Unlike mt_cyclical, this is a total order (there is no interval to
compare - see mt_duration-compare), so Allen's interval algebra
(%p%, %m%, ...) is not supported, matching mt_duration's own
documented exclusion.
Usage
# S4 method for class 'mt_cyclical_free'
e1 == e2
# S4 method for class 'mt_cyclical_free'
e1 != e2
# S4 method for class 'mt_cyclical_free'
e1 < e2
# S4 method for class 'mt_cyclical_free'
e1 <= e2
# S4 method for class 'mt_cyclical_free'
e1 > e2
# S4 method for class 'mt_cyclical_free'
e1 >= e2