fairdm.core.dates#

Precision-aware comparison of the partial dates a record carries.

A PartialDate mixes precision into its own ordering (self.date >= other.date and self.precision >= other.precision), so comparing two values of different precision directly is unsafe. precedes() is the one implementation of the precision-aware comparison every date rule needs.

Module Contents#

Functions#

precedes

Return whether one partial date is earlier than another.

API#

precedes(a: partial_date.PartialDate, b: partial_date.PartialDate) → bool[source]#

Return whether one partial date is earlier than another.

Compares at the coarser of the two precisions: years only if either is year-precision, year and month if either is month-precision, and the full date only when both carry day precision.

Args: a: The date expected to come first. b: The date expected to come second.

Returns: True when a is earlier than b at their shared precision.