Difference between revisions of "Age"
From Sega Retro
Line 1: | Line 1: | ||
− | <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}}}}} | + | <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: {{#var:date2_m}} > {{month|{{{1}}}}} |
− | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}}} | + | | {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}}} |
− | }}{{#ifexpr: {{date2_m}} < {{month|{{{1}}}}} | + | }}{{#ifexpr: {{#var:date2_m}} < {{month|{{{1}}}}} |
− | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}-1}} | + | | {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}-1}} |
− | }}{{#ifexpr: {{date2_m}} = {{month|{{{1}}}}} | + | }}{{#ifexpr: {{#var:date2_m}} = {{month|{{{1}}}}} |
− | | {{#ifexpr: {{date2_d}} > {{#sub:{{{1}}}|8|2}} | + | | {{#ifexpr: {{#var:date2_d}} > {{#sub:{{{1}}}|8|2}} |
− | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}}} | + | | {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}}} |
− | }}{{#ifexpr: {{date2_d}} < {{#sub:{{{1}}}|8|2}} | + | }}{{#ifexpr: {{#var:date2_d}} < {{#sub:{{{1}}}|8|2}} |
− | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}-1}} | + | | {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}-1}} |
− | }}{{#ifexpr: {{date2_d}} = {{#sub:{{{1}}}|8|2}} | + | }}{{#ifexpr: {{#var:date2_d}} = {{#sub:{{{1}}}|8|2}} |
− | | {{#expr:{{date2_y}}-{{year|{{{1}}}}}}} | + | | {{#expr:{{#var:date2_y}}-{{year|{{{1}}}}}}} |
}} | }} | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> |
Revision as of 02:33, 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: Unexpected > operator.Expression error: Unexpected < operator.Expression error: Unexpected = operator.
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: Unexpected > operator.Expression error: Unexpected < operator.Expression error: Unexpected = operator.