Nodyn:Age in years and days

Oddi ar Wicipedia
Documentation icon Dogfennaeth nodyn[gweld] [golygu] [hanes] [puro]

This template returns the number of full years and surplus days between two specified dates. If the second set of parameters is not included, it will return the number of full years and surplus days between a specified date and today's date. The two numbers are separated by a comma; the words "year" and "day" are plural when appropriate. The {{number table sorting}} template is included in the year value, so that values produced by this template will work properly in sortable lists. See Wikipedia:Age calculation templates for more information on using this kind of template.

Syntax[golygu cod]

{{Age in years and days|yyyy|mm|dd}} or
{{Age in years and days|yyyy|mm|dd|yyyy2|mm2|dd2}}

Examples[golygu cod]

{{Age in years and days|1989|07|23}} returns "700134000000000000034 blynedd, 7002240000000000000240 diwrnod"
{{Age in years and days|1989|07|23|2003|07|24}} returns "700114000000000000014 blynedd, 70001000000000000001 diwrnod"

Notes[golygu cod]

This template does not check for incorrect input:

{{Age in years and days|1980|07|14|1993|06|233}} returns "Error: Gwall: Second date should be year month day This is not a valid number. Please refer to the documentation at {{number table sorting}} for correct input. blynedd, Error: Gwall: Second date should be year month day This is not a valid number. Please refer to the documentation at {{number table sorting}} for correct input. diwrnod" (surplus days do not count as extra months)
{{Age in years and days|1980|07|14|1993|88|14}} returns "Error: Gwall: Second date should be year month day This is not a valid number. Please refer to the documentation at {{number table sorting}} for correct input. blynedd, Error: Gwall: Second date should be year month day This is not a valid number. Please refer to the documentation at {{number table sorting}} for correct input. diwrnod" (surplus months do not count as extra years)

Also note that due to leap years, the measure "years and days" fails to be fully additive. The following example is not an error, but each calculation uses a different definition of "year", either 365 days or 366:

{{Age in years and days|2007|02|27|2008|03|02}} returns "70001000000000000001 mlynedd, 70004000000000000004 diwrnod"

but split up:

{{Age in years and days|2007|02|27|2007|03|02}} returns "50000000000000000000 blynedd, 70003000000000000003 diwrnod"
{{Age in years and days|2007|03|02|2008|03|02}} returns "70001000000000000001 mlynedd, 50000000000000000000 diwrnod"

See also[golygu cod]