Functional Weave
Code in TypeScript

health.age-in-months@1.0.1

README.md

2,905 bytes · view raw

# health.age-in-months

A child's age as completed months plus days on a given date: born 10 March
2026, on 25 May 2026 the child is 2 months 15 days. Paediatric growth charts,
immunisation schedules and many dosing tables are read in months, and the
date to measure on is an argument, never the clock. `totalDays` is the age in
days as well, for neonates.

**When a month is completed.** A month is completed on the same day of the
month as the birth. When that day does not exist in the month (born 31
January; born 29 February in a common year), the month is completed on the
first day of the following month, not on the last day of the short month.
Born 31 January 2026, the child is 0 months 28 days on 28 February and
1 month 0 days on 1 March. This is the same rule `dates.age` applies to a
29 February birthday (the anniversary is 1 March), so a child born 29
February 2024 is 11 months 30 days on 28 February 2025 and 12 months, and
one year old, on 1 March 2025. A naive "add a month and clamp" says the
child born on 31 January is a month old on 28 February, three days early.

Months are always counted from the date of birth, not stepped a month at a
time, so a 31st-of-the-month birthday does not decay to the 28th after
February: born 31 January, 2 months are completed on 31 March.

A measuring date before the birth date is an error, not a negative age. Dates
are ISO `YYYY-MM-DD`; an impossible date (2026-02-30) or a UK-style
`15/05/2026` is an error.

Built on `dates.add-months` and `dates.add-days`; no clinical thresholds are
applied here.

## Before you rely on this

**Not professional advice.** This capability calculates health figures from published rules. It is a software component for developers, not medical advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have a clinician review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.

**Not a medical device.** It is not intended to diagnose, treat or support clinical decisions about any individual. Anyone building it into clinical software is responsible for that software's regulatory status, and must validate it under their own clinical governance.

**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified clinician has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.

1.0.1 marks it unreviewed. The code and the tests are unchanged.