Template:Birth date and age: Difference between revisions

From Bhikitia Pro, An open encyclopedia
Blossom (talk | contribs)
No edit summary
Blossom (talk | contribs)
No edit summary
Line 3: Line 3:
</noinclude>
</noinclude>
<includeonly>
<includeonly>
{{#if: {{{1|}}} <!-- Check if a birth year is provided -->
{{#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 if birthday hasn't occurred this year -->
        | -1 <!-- Subtract 1 year if the current date is before the birthdate -->
      | 0
        | 0
      }}
     }}})
     }}})
   | ''No date provided'' <!-- Default text if no date is provided -->
   | ''No date provided'' <!-- Default text if no date is provided -->
}}
}}
</includeonly>
</includeonly>

Revision as of 16:51, 10 December 2024