Template:Birth date and age: Difference between revisions
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
</noinclude> | </noinclude> | ||
<includeonly> | <includeonly> | ||
{{#if: {{{1|}}} <!-- Check if | {{#if: {{{1|}}} <!-- Check if the first parameter (birthdate) is provided --> | ||
| {{#time:j F Y|{{{1}}}}} <!-- Format the birth date --> | | {{#time:j F Y|{{{1}}}}} <!-- Format the birth date (e.g., 21 September 1934) --> | ||
({{#expr: {{CURRENTYEAR}} - {{#time:Y|{{{1}}}}} <!-- Calculate age --> | ({{#expr: {{CURRENTYEAR}} - {{#time:Y|{{{1}}}}} <!-- Calculate age --> | ||
{{#ifexpr: {{CURRENTMONTH}} < {{#time:n|{{{1}}}}} or ({{CURRENTMONTH}} = {{#time:n|{{{1}}}}} and {{CURRENTDAY}} < {{#time:j|{{{1}}}}}) | {{#ifexpr: {{CURRENTMONTH}} < {{#time:n|{{{1}}}}} or ({{CURRENTMONTH}} = {{#time:n|{{{1}}}}} and {{CURRENTDAY}} < {{#time:j|{{{1}}}}}) | ||
| -1 <!-- Subtract 1 year if the current date is before the birthdate --> | |||
| 0 | |||
}} | |||
}}}) | }}}) | ||
| ''No date provided'' <!-- Default text if no date is provided --> | | ''No date provided'' <!-- Default text if no date is provided --> | ||
}} | }} | ||
</includeonly> | </includeonly> | ||