Template:Age in years and days/doc

From Exordium Wiki

Page Module:Message box/ombox.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").

Page Module:Message box/ombox.css must have content model "Sanitized CSS" for TemplateStyles (current model is "plain text").

This template returns the number of full years and surplus days between two specified dates. If only one date is entered, the template returns the number of full years and surplus days between the specified date and today's date.

This template does not generate a sort key. In a sortable table, use {{ayd}} which redirects to {{age in years and days nts}}.

Usage[edit source]

Each date can be entered in a single parameter, or each date can be entered as three parameters: year, month, day.

  • {{age in years and days|15 May 2010}}&Expression error: Unexpected < operator.Error: Need valid year, month, day years, &Expression error: Unexpected < operator.Error: Need valid year, month, day days
  • {{age in years and days|12 Aug 2003|24 Sep 2011}}&Expression error: Unexpected < operator.Error: Need valid year, month, day years, &Expression error: Unexpected < operator.Error: Need valid year, month, day days
  • {{age in years and days|1989|7|23}}&000000000000003400000034 years, &0000000000000364000000364 days
  • {{age in years and days|1989|7|23|2003|7|24}}&000000000000001400000014 years, &00000000000000010000001 day
  • {{age in years and days|2007-03-02|2008-03-02}}&Expression error: Unexpected < operator.Error: Need valid year, month, day years, &Expression error: Unexpected < operator.Error: Need valid year, month, day days

An error is shown if an entered date is not valid (1900 was not a leap year).

  • {{age in years and days|31 January 1892|29 February 1900}}Error: Second date should be year, month, day

Options[edit source]

The default is to separate years and days with a comma. The separator is "and" if |sep=and is used.

The default calculates an age—the day of the second date is not included in the calculation. A duration including the second date is calculated if |duration=on is used.

  • {{age in years and days|1 Jan 2011|31 Dec 2012}}&Expression error: Unexpected < operator.Error: Need valid year, month, day years, &Expression error: Unexpected < operator.Error: Need valid year, month, day days
  • {{age in years and days|1 Jan 2011|31 Dec 2012|sep=and}}&Expression error: Unexpected < operator.Error: Need valid year, month, day years, &Expression error: Unexpected < operator.Error: Need valid year, month, day days
  • {{age in years and days|1 Jan 2011|31 Dec 2012|duration=on}}&Expression error: Unexpected < operator.Error: Need valid year, month, day years, &Expression error: Unexpected < operator.Error: Need valid year, month, day days

TemplateData[edit source]

<templatedata> { "params": { "1": { "label": "Earlier date", "description": "The earlier date being compared", "type": "date", "required": true }, "2": { "label": "Later date", "description": "The later date being compared", "type": "date", "default": "Today's date", "suggested": true }, "sep": { "label": "Separator", "description": "Defines a custom separator between the years and days", "type": "string", "suggestedvalues": [ "and" ], "default": "," }, "duration": { "label": "Duration?", "description": "Set to \"on\" to include the second date in the calculation; will return a result one higher than if left off", "type": "boolean" } }, "description": "Returns the number of full years and surplus days between two specified dates (or, if only one date is entered, between the specified date and today's date)", "paramOrder": [ "1", "2", "sep", "duration" ], "format": "inline" } </templatedata>