Difference between revisions of "Age"
From Sega Retro
(Created page with "<includeonly>{{#ifexpr: {{CURRENTMONTH}} > {{month|{{{1}}}}} | {{#expr:{{CURRENTYEAR}}-{{year|{{{1}}}}}}} }}{{#ifexpr: {{CURRENTMONTH}} < {{month|{{{1}}}}} | {{#expr:{{CURRENT...") |
|||
Line 1: | Line 1: | ||
− | <includeonly>{{#ifexpr: {{ | + | <includeonly>{{#if: {{{2|}}} | {{#var_define:date2_y|{{year|{{{2}}}}}}}{{#var_define:date2_m|{{month|{{{2}}}}}}}{{#var_define:date2_d|{{#sub:{{{2}}}|8|2}}}} | {{#var_define:date2_y|{{CURRENTYEAR}}}}{{#var_define:date2_m|{{CURRENTMONTH}}}}{{#var_define:date2_d|{{CURRENTDAY}}}} }}{{#ifexpr: {{date2_m}} > {{month|{{{1}}}}} |
− | | {{#expr:{{ | + | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}}} |
− | }}{{#ifexpr: {{ | + | }}{{#ifexpr: {{date2_m}} < {{month|{{{1}}}}} |
− | | {{#expr:{{ | + | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}-1}} |
− | }}{{#ifexpr: {{ | + | }}{{#ifexpr: {{date2_m}} = {{month|{{{1}}}}} |
− | | {{#ifexpr: {{ | + | | {{#ifexpr: {{date2_d}} > {{#sub:{{{1}}}|8|2}} |
− | | {{#expr:{{ | + | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}}} |
− | }}{{#ifexpr: {{ | + | }}{{#ifexpr: {{date2_d}} < {{#sub:{{{1}}}|8|2}} |
− | | {{#expr:{{ | + | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}-1}} |
− | }}{{#ifexpr: {{ | + | }}{{#ifexpr: {{date2_d}} = {{#sub:{{{1}}}|8|2}} |
− | | {{#expr:{{ | + | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}}} |
}} | }} | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
Line 20: | Line 20: | ||
{{age|1991-06-23}} | {{age|1991-06-23}} | ||
+ | |||
+ | ===Optional parameter=== | ||
+ | Add a second date to calculate the age on that date. | ||
+ | |||
+ | <tt><nowiki>{{</nowiki>age|1991-06-23|1999-09-09}}</tt> | ||
+ | |||
+ | returns | ||
+ | |||
+ | {{age|1991-06-23|1999-09-09}} | ||
[[Category:Sega Retro templates]]</noinclude> | [[Category:Sega Retro templates]]</noinclude> |
Revision as of 02:32, 29 July 2015
Convert a date in the format YYYY-MM-DD to an age in years (based on the current date).
Usage
{{age|1991-06-23}}
returns
{{#var_define:date2_y|2024}}{{#var_define:date2_m|11}}{{#var_define:date2_d|6}}Expression error: Unrecognized punctuation character "[".Expression error: Unrecognized punctuation character "[".Expression error: Unrecognized punctuation character "[".
Optional parameter
Add a second date to calculate the age on that date.
{{age|1991-06-23|1999-09-09}}
returns
{{#var_define:date2_y|1999}}{{#var_define:date2_m|09}}{{#var_define:date2_d|09}}Expression error: Unrecognized punctuation character "[".Expression error: Unrecognized punctuation character "[".Expression error: Unrecognized punctuation character "[".