Completed years from a birth Day to a Day, with an explicit leap policy.
The leap policy is REQUIRED, with no default: a birth on 29 February has no anniversary in a common year, and WHICH day it completes on is a legal statement, not arithmetic. The statute lives in the consumer (calendario binds :leap/mar-01, Codigo Civil art. 132 paragraph 3); the arithmetic lives here.
:leap/feb-28 -- the birthday falls on 28 February in a common year; :leap/mar-01 -- it falls on 1 March (the next day).
The arithmetic stays integer calendar arithmetic: y = day.year - birth.year, minus 1 when the (month, day) pair has not yet arrived. Never days/365.25, never day-of-year, never a plusYears loop.
A missing or unknown policy is refused with its OWN reason (:time/leap-policy-missing, :time/leap-policy-unknown), distinct from the before-birth refusal (:time/age-before-birth).
Completed years from a birth Day to a Day, with an explicit leap policy. The leap policy is REQUIRED, with no default: a birth on 29 February has no anniversary in a common year, and WHICH day it completes on is a legal statement, not arithmetic. The statute lives in the consumer (calendario binds :leap/mar-01, Codigo Civil art. 132 paragraph 3); the arithmetic lives here. :leap/feb-28 -- the birthday falls on 28 February in a common year; :leap/mar-01 -- it falls on 1 March (the next day). The arithmetic stays integer calendar arithmetic: y = day.year - birth.year, minus 1 when the (month, day) pair has not yet arrived. Never days/365.25, never day-of-year, never a plusYears loop. A missing or unknown policy is refused with its OWN reason (:time/leap-policy-missing, :time/leap-policy-unknown), distinct from the before-birth refusal (:time/age-before-birth).
(completed-years birth day leap-policy)Completed years of birth as of day, under leap-policy (from the closed set).
In a LEAP year 29 February exists, so a 29 February birth completes on 29 February under BOTH policies; the policies differ ONLY in a common year, where :leap/feb-28 completes on 28 February and :leap/mar-01 on 1 March.
day before birth -> :time/age-before-birth; a policy outside the set -> :time/leap-policy-unknown; a nil policy -> :time/leap-policy-missing.
Completed years of birth as of day, under leap-policy (from the closed set). In a LEAP year 29 February exists, so a 29 February birth completes on 29 February under BOTH policies; the policies differ ONLY in a common year, where :leap/feb-28 completes on 28 February and :leap/mar-01 on 1 March. day before birth -> :time/age-before-birth; a policy outside the set -> :time/leap-policy-unknown; a nil policy -> :time/leap-policy-missing.
(leap-policy? p)True when p is a leap policy in the closed set.
True when p is a leap policy in the closed set.
The CLOSED set of leap policies, as a malli :enum.
The CLOSED set of leap policies, as a malli :enum.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |