Jump to content

Template:Birth based on age as of date: Difference between revisions

From NicheWork
w>Chaotic Enby
Officially moving it to use the Lua module, been tested on testcases (with the module-based template actually giving the correct results in cases where the earlier implementation failed)
 
m 1 revision imported
 
(No difference)

Latest revision as of 13:40, 19 January 2026

Template documentation

For a person whose date of birth is unknown, this template estimates the person's birth year and current age based on a given age at a certain date. This is useful when a reliable source states only their age at the time of publication.

If the subject has died, please use {{Birth based on age at death}} instead of this template. While as of 2024 that template is just a wrapper of this one, this leaves open the possibility to use that template to recategorize the subject. Also, it makes sure you don't forget to suppress the age field.

Syntax

Typical use

 {{birth based on age as of date | age | year | month | day }}
Code:
{{birth based on age as of date|50|2024|12|25}}
Result:
1973 or 1974 (age 51–52)

The age, year, and day must be supplied as natural numbers; month can be specified as a natural number as well as by name or abbreviation (e.g. "August" or "Aug"). The Gregorian calendar is assumed, with no special support provided for dual dating or the difference between Old Style and New Style dates.

If only the publication year for a source is known, the "day" and "month" fields can be omitted.

No age

In some contexts—like the lead sentence of a biography—it may be desirable to show only the birth year, and not a person’s age. To suppress the age field, set |noage=any value:

Code:
{{birth based on age as of date|50|2024|12|25|noage=yes}}
{{birth based on age as of date|50|2024|12|25|noage=1}}
Result:
1973 or 1974
1973 or 1974
Note
The parameter |noage= was added April 2013 and initially only accepted a value of 1, such as |noage=1. It was updated July 2019 to accept any value, such as |noage=yes.

Slash separator

In general, the two possible birth years should be written out as: 1950 or 1951. In contexts which are tight for space, the separator between the two possible years should be a slash: 1950/1951.

To use the / separator, add |slash=any value.

Code:
{{birth based on age as of date|50|2024|12|25|slash=yes}}
{{birth based on age as of date|50|2024|12|25|slash=1}}
Result:
1973/1974 (age 51–52)
1973/1974 (age 51–52)
Note
The parameter |slash= was added April 2023 when the template was updated to separate years with or instead of /. It replaced the now deprecated parameter |mos=, which was added November 2015 and removed July 2023.

Multiple dates

 {{birth based on age as of date | age | year | month | day | age | year | month | day }}
Code:
{{birth based on age as of date|50|2024|12|25|51|2024|12|31}}
Result:
1973 (age 52)

Two or more dates can be entered, using the same format as for a single date. In this case, the "day" and "month" fields cannot be omitted.

Examples

If, for example, a reference dated July 4, 2024 mentions that someone is 50 years old, that person's birth year and age can be rendered using:

{{birth based on age as of date|50|2024|July|4}}

The following examples are for a person reported as being 50 years old in 2025

Template code Result
{{birth based on age as of date|50|2025|01|25}} 1974 or 1975 (age 50–51)
{{birth based on age as of date|50|2025|January|25}} 1974 or 1975 (age 50–51)
{{birth based on age as of date|50|2025|12|31}} 1975 (age 50–51)
{{birth based on age as of date|50|2025|Jan|1}} 1974 or 1975 (age 51–52)
{{birth based on age as of date|50|2025|12|31|slash=yes}} 1975 (age 50–51)
{{birth based on age as of date|50|2025|Jan|1|slash=1}} 1974/1975 (age 51–52)
{{birth based on age as of date|50|2025|12|31|noage=yes}} 1975
{{birth based on age as of date|50|2025|Jan|1|noage=1}} 1974 or 1975
{{birth based on age as of date|50|2025|12|31|noage=yes|slash=yes}} 1975
{{birth based on age as of date|50|2025|Jan|1|noage=1|slash=1}} 1974/1975
{{birth based on age as of date|50|2025|January}} 1974 or 1975 (age 50–51)
{{birth based on age as of date|50|2025|Jan}} 1974 or 1975 (age 50–51)
{{birth based on age as of date|50|2025|12}} 1974 or 1975 (age 50–51)
{{birth based on age as of date|50|2025}} 1974 or 1975 (age 50–51)
{{birth based on age as of date|50|2024|12|25|51|2024|12|31}} 1973 (age 52)

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Birth based on age as of date

[[Category:Templates using TemplateData{{#translation:}}]]

<templatedata> { "params": { "1": { "label": "Age", "description": "Age of subject at date of reference's publication.", "example": "55", "type": "number", "required": true }, "2": { "label": "Year", "description": "Year of publication of reference.", "example": "1950", "type": "number", "required": true }, "3": { "label": "Month", "description": "Month of publication of reference.", "example": "8 or August", "type": "string", "suggested": true }, "4": { "label": "Day", "description": "Day of publication of reference.", "example": "21", "type": "number", "suggested": true }, "noage": { "label": "Hide age", "description": "Set to any value to display birth years without the ages. If this parameter is omitted or contains no value, the age is displayed.", "type": "boolean", "required": false, "suggestedvalues": [ "yes", "y", "1" ] }, "slash": { "label": "Slash separator", "description": "Set to any value to separate birth years with a '/' for tight spaces (e.g., table cells). If this parameter is omitted or contains no value, birth years are separated with ' or '.", "type": "boolean", "required": false, "suggestedvalues": [ "yes", "y", "1" ] } }, "description": "For a person whose date of birth is unknown, this template estimates the person's birth year and current age based on a given age at a certain date.", "format": "inline", "paramOrder": [ "1", "2", "3", "4", "noage", "slash" ] } </templatedata>

Tracking category

See also