Template:Years and days/doc
{{#ifeq:doc |doc
|
{{#ifeq:show |show
|
| icon | This is a documentation subpage for Template:Years and days{{#if:||.}} It may contain usage information, categories and other content that is not part of the original {{#if: |{{{text2}}} |{{#if: |{{{text1}}} |{{#ifeq:Template |User |template template page |{{#if:Template |template page|article}}}}}}}}. |
}}{{#if:|
|{{#ifexist:Template:Years and days
| [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
|
}}
}}
|
}}
The Template:Years_and_days shows the equivalent years and days for a count in days, with singular words when 1 year or 1 day. A year is treated as 365.25 days, where 366 days is "1 year, 1 day". The purpose of the template is to reduce a large count of days into the years/days format, but also handle small counts of days as just "n days".
{{#if: ||+ {{{title}}}}} {{#if: || Markup | Renders as
}}{{#if:{{Years and days|888}}| | |||||||||||||||||
| padding:;}} "| {{#switch:
|
none = {{Years and days|888}} | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup">{{Years and days|888}}</syntaxhighlight> | pre = {{Years and days|888}}
|
#default = < style="">{{Years and days|888}}</> }} | padding:;}} "| {{
|
no | <span class="tmp-color" | <span
}} |
Template | <span class="tmp-color" | {Years and days}: Expected count of days, but found: 888 }}{{
|
{{#ifexpr: 888 < 2*365 | 1 year, | {{
#expr: floor( 888 / 365.25 )}} years,
}}{{
#expr: ( 888 - floor( 888 / 365.25 )*365.25 ) round 0
}} days
|
{{#switch: 888 | 1 = 1 day | 365 = 1 year | #default = 888 days
}} }} }}{{#if:{{Years and days|365}}| |
| padding:;}} "| {{#switch:
|
none = {{Years and days|365}} | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup">{{Years and days|365}}</syntaxhighlight> | pre = {{Years and days|365}}
|
#default = < style="">{{Years and days|365}}</> }} | padding:;}} "| {{
|
no | <span class="tmp-color" | <span
}} |
Template | <span class="tmp-color" | {Years and days}: Expected count of days, but found: 365 }}{{
|
{{#ifexpr: 365 < 2*365 | 1 year, | {{
#expr: floor( 365 / 365.25 )}} years,
}}{{
#expr: ( 365 - floor( 365 / 365.25 )*365.25 ) round 0
}} days
|
{{#switch: 365 | 1 = 1 day | 365 = 1 year | #default = 365 days
}} }} }}{{#if:{{Years and days|4200}}| |
| padding:;}} "| {{#switch:
|
none = {{Years and days|4200}} | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup">{{Years and days|4200}}</syntaxhighlight> | pre = {{Years and days|4200}}
|
#default = < style="">{{Years and days|4200}}</> }} | padding:;}} "| {{
|
no | <span class="tmp-color" | <span
}} |
Template | <span class="tmp-color" | {Years and days}: Expected count of days, but found: 4200 }}{{
|
{{#ifexpr: 4200 < 2*365 | 1 year, | {{
#expr: floor( 4,200 / 365.25 )}} years,
}}{{
#expr: ( 4200 - floor( 4200 / 365.25 )*365.25 ) round 0
}} days
|
{{#switch: 4200 | 1 = 1 day | 365 = 1 year | #default = 4200 days
}} }} }}{{#if:{{Years and days|7000100}}| |
| padding:;}} "| {{#switch:
|
none = {{Years and days|7000100}} | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup">{{Years and days|7000100}}</syntaxhighlight> | pre = {{Years and days|7000100}}
|
#default = < style="">{{Years and days|7000100}}</> }} | padding:;}} "| {{
|
no | <span class="tmp-color" | <span
}} |
Template | <span class="tmp-color" | {Years and days}: Expected count of days, but found: 7000100 }}{{
|
{{#ifexpr: 7000100 < 2*365 | 1 year, | {{
#expr: floor( 7,000,100 / 365.25 )}} years,
}}{{
#expr: ( 7000100 - floor( 7000100 / 365.25 )*365.25 ) round 0
}} days
|
{{#switch: 7000100 | 1 = 1 day | 365 = 1 year | #default = 7000100 days
}} }} }}{{#if:| |
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }}{{#if:| | |||||||||||||
| padding:;}} "| {{#switch:
|
none = | syntaxhighlight = <syntaxhighlight lang="wikitext" inline="1" style="" class="markup-markup"></syntaxhighlight> | pre = | #default = < style=""></> }} | padding:;}} "| }} |
The count of days can range from 0 to many millions, billions, etc, but you should be aware of false precision if giving a long period of time to the nearest day.
See also
[edit source]- Template:Time ago – show interval from past date to current
- Template:Birth date_and age – show birthdate and age in years
- Template:Days since – shows days since a specific month|day|year.