Functional Weave
Code in Python

dates.age@1.0.0

README.md

1,902 bytes · view raw

# dates.age

Completed years on a date: someone born on 15 May 1990 is 35 on 14 May 2026
and 36 on 15 May 2026. The date to measure on is an argument, never the clock,
so "was this customer 18 when they signed?" and "how old is this employee
today?" are the same call with a different date.

A person attains an age at the start of the anniversary of their birth. For
someone born on 29 February, the anniversary in a year with no 29 February is
taken to be 1 March, so they turn 18 on 1 March, not 28 February. That is the
UK convention:

- Scotland states it outright. Age of Legal Capacity (Scotland) Act 1991,
  section 6: "(1) The time at which a person attains a particular age expressed
  in years shall be taken to be the beginning of the relevant anniversary of
  the date of his birth. (2) Where a person has been born on 29th February in a
  leap year, the relevant anniversary in any year other than a leap year shall
  be taken to be 1st March."
  https://www.legislation.gov.uk/ukpga/1991/50/section/6
- England, Wales and Northern Ireland: Family Law Reform Act 1969, section
  9(1), "The time at which a person attains a particular age expressed in years
  shall be the commencement of the relevant anniversary of the date of his
  birth." https://www.legislation.gov.uk/ukpga/1969/46/section/9 . The Act
  does not name the anniversary of a 29 February birth; 1 March is the reading
  applied in practice and the one the Scottish Act writes down.

Some other jurisdictions and systems use 28 February instead. The difference
is one day every three years in four, and it is exactly the day an age-gated
sale or a pension start date is checked on, so this capability picks the UK
rule and says so rather than leaving it to whatever a naive clamp does.

A measuring date before the birth date is an error rather than a negative or
zero age: it is always a data or argument-order mistake.