Jump to content

Template:Years and days/doc

From The Furrydelphia Wiki

{{#ifeq:doc |doc

    | 

{{#ifeq:show |show

|

        }}{{#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:;}} "|

{{

  1. ifeq: 888|xnone|
  
{{ safesubst:#if:
no <span class="tmp-color" <span

}}

Template <span class="tmp-color" {Years and days}: Expected count of days, but found: 888

}}{{

  1. ifexpr: 888 > 365
{{#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:;}} "|

{{

  1. ifeq: 365|xnone|
  
{{ safesubst:#if:
no <span class="tmp-color" <span

}}

Template <span class="tmp-color" {Years and days}: Expected count of days, but found: 365

}}{{

  1. ifexpr: 365 > 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:;}} "|

{{

  1. ifeq: 4200|xnone|
  
{{ safesubst:#if:
no <span class="tmp-color" <span

}}

Template <span class="tmp-color" {Years and days}: Expected count of days, but found: 4200

}}{{

  1. ifexpr: 4200 > 365
{{#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:;}} "|

{{

  1. ifeq: 7000100|xnone|
  
{{ safesubst:#if:
no <span class="tmp-color" <span

}}

Template <span class="tmp-color" {Years and days}: Expected count of days, but found: 7000100

}}{{

  1. ifexpr: 7000100 > 365
{{#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]