Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Birth date and age: Difference between revisions

Template page
Blossom (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit Advanced mobile edit
Blossom (talk | contribs)
No edit summary
Line 1: Line 1:
{{#switch: {{{1|}}}
<noinclude>
| year = {{#expr: {{CURRENTYEAR}} - {{{2}}} }}
{{Documentation}}
| full = {{Birth date and age|{{{2}}}|{{{3}}}|{{{4}}}}}
</noinclude>
| default = {{#expr: {{CURRENTYEAR}} - {{{2}}} }} years old
<includeonly>
{{#if: {{{1|}}} <!-- Check if a birth year is provided -->
  | {{#time:j F Y|{{{1}}}}} <!-- Format the birth date -->
    ({{#expr: {{CURRENTYEAR}} - {{#time:Y|{{{1}}}}} <!-- Calculate age -->
      {{#ifexpr: {{CURRENTMONTH}} < {{#time:n|{{{1}}}}} or ({{CURRENTMONTH}} = {{#time:n|{{{1}}}}} and {{CURRENTDAY}} < {{#time:j|{{{1}}}}})
      | -1 <!-- Subtract 1 if birthday hasn't occurred this year -->
      | 0
    }}})
  | ''No date provided'' <!-- Default text if no date is provided -->
}}
}}
</includeonly>

Revision as of 16:48, 10 December 2024

Your wiki got a version of Template:Documentation that is only relevant to Templates Wiki! Click here to revert it. For a documentation template you can use on your wiki, see Template:Documentation (copy) on Templates Wiki.
Template information, documentation, and installation instructions.
Expand the below text for usage and other information.

Template Documentation:
Note: The template above might be broken without the parameters; this is normal.
View, edit, or check the history of this documentation. (How does this work?)
Editors can experiment with this template's sandbox and testcases.
Note
Date defaults to Jan 1, 1990 (1 Jan 1990 or 1990/1/1).
Dependencies
Parameters
  • 1 = year #
    • year = alternate year #
  • 2 = month #
    • month = alternate month #
  • 3 = day #
    • day = alternate day #
  • df=yes or df=1 show date in day number first (DD Month YYYY) format
Examples
  • {{Birth date and age|year=1929|month=1|day=15}}

{{#if:

 | Error: Invalid time. 
   (Expression error: Unexpected < operator.
  • {{Birth date and age|1976|7|4}}

{{#if: 1976

 | 15 July 1976 
   (Expression error: Unexpected number.
  • {{Birth date and age|1929|1|15|df=yes}}

{{#if: 1929

 | 15 July 1929 
(Expression error: Unexpected number.

Installation Instructions
Export this template, then import to install it.
Use edit summary: Copied from [[w:c:templates:Template:Birth date and age]] to properly attribute this template's editors.
There is no additional installation instructions for this template. If there is any, you may create it at Template:Birth date and age/install.