Difference between revisions of "Template:CAD"

From blackwiki
Jump to navigation Jump to search
imported>Stepho-wrs
imported>Djr13
(copy logic from Template:US$ as of revision 710153226, which has several improvements)
Line 1: Line 1:
<span style="white-space: nowrap"><includeonly>{{#ifeq:{{{link|no}}}|yes
+
<span style="white-space: nowrap">{{#ifeq:{{{link|no}}}|yes
 
  |[[Canadian dollar|CA$]]
 
  |[[Canadian dollar|CA$]]
 
  |CA$
 
  |CA$
}}{{#if:{{{1|}}}|{{formatnum:{{{1}}}}}}}</span>{{#if:{{{year|{{{2|}}}}}}
+
}}{{formatnum:{{{1|}}}}}</span><!--
|{{#ifexpr:{{{year|{{{2|}}}}}}<{{CURRENTYEAR}}
+
-->{{#ifeq:{{{year|{{{2|0}}}}}}|0||{{#ifexpr:{{Inflation/CA/startyear}}<={{{year|{{{2|0}}}}}} and {{{year|{{{2|0}}}}}}<{{Inflation-year|CA}}
  |{{#ifexpr:{{{year|{{{2|}}}}}}>1799
+
|&#32;({{#if:{{{about|}}}
  |&#32;({{#if:{{{about|}}}
+
  |equivalent to about ${{formatnum:{{Inflation|CA|{{formatnum:{{{1|}}}|R}}|{{{year|{{{2}}}}}}|r={{{round|0}}}}}}}
    |about ${{formatnum:{{Inflation|CA|{{formatnum: {{{1|}}}|R}}|{{{year|}}}{{{2|}}}|r={{{round|0}}}}}}}
+
  |equivalent to ${{formatnum:{{Inflation|CA|{{formatnum:{{{1|}}}|R}}|{{{year|{{{2}}}}}}|r={{{round|{{#ifexpr:{{Inflation|CA|{{formatnum:{{{1|}}}|R}}|{{{year|{{{2}}}}}}}}>1000|0|2}}}}}}}}}
    |${{formatnum:{{Inflation|CA|{{formatnum:{{{1|}}}|R}}|{{{year|}}}{{{2|}}}|r={{{round|{{#ifexpr:{{Inflation|CA|{{formatnum:{{{1|}}}|R}}|{{{year|}}}{{{2|}}}}}>1000|0|2}}}}}}}}}
+
}} in {{Inflation-year|CA}})
  }} in {{CURRENTYEAR}})
+
}}}}<noinclude>
  }}
 
}}
 
}}</includeonly><noinclude>
 
 
{{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
{{documentation}}<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 
</noinclude>

Revision as of 09:50, 15 March 2016

CA$

Template documentation[view] [edit] [history] [purge]

This is a multifunction template. At its simplest, it adds the currency mark "CA$", as recommended by MOS:CURRENCY for many situations. The template can also link to the Canadian dollar article and can even calculate inflation. See warnings below.

Usage

{{CAD|number}}

Additional text like "million" or "trillion" must be placed outside the template, typically preceded by a non-breaking space (see example below).

Example:

  • {{CAD}}CA$
  • {{CAD|123.45}}CA$123.45
  • {{CAD|123}}{{nbsp}}millionCA$123 million

Link

The parameter |link=yes may be used to link CA$ to the article Canadian dollar. This is turned off by default, but may be appropriate for the first occurrence of the term in an article.

Example:

  • {{CAD|123.45|link=yes}}CA$123.45

Inflation calculation

The template supports inflation calculation, by way of {{Inflation}}. If the second parameter is used, to specify a year, and this year is within a certain range of available inflation data (specifically, if 1914 ≤ year < 2018), the equivalent value represented in 2018 dollars will be calculated in parentheses. However, this function should only be used in appropriate situations.

  • {{CAD|value|year}}
  • {{CAD|value|year|round=round|about=yes}}

Examples:

  • {{CAD|100|1913}}CA$100
  • {{CAD|100|1914}}CA$100 (equivalent to $2,223 in 2018)
  • {{CAD|100|1966}}CA$100 (equivalent to $762.29 in 2018)
  • {{CAD|100|1966|link=yes}}CA$100 (equivalent to $762.29 in 2018)
  • {{CAD|100|2017}}CA$100 (equivalent to $102.3 in 2018)
  • {{CAD|100|2018}}CA$100
  • {{CAD|100|2025}}CA$100
  • {{CAD|100|2026}}CA$100

Additional parameter |about=yes will cause the template to calculate to the nearest dollar (instead of the nearest cent), and prefix the calculated value with "about". The rounding can be fine-tuned further by using |round=integer. These parameters may be combined.

Examples:

  • {{CAD|10|1935}}CA$10 (equivalent to $182.74 in 2018)
  • {{CAD|10|1935|round=0}}CA$10 (equivalent to $183 in 2018)
  • {{CAD|10|1935|about=yes}}CA$10 (equivalent to about $183 in 2018)
  • {{CAD|1000|1935|round=2}}CA$1,000 (equivalent to $18,273.97 in 2018)
  • {{CAD|1000|1935|round=-2}}CA$1,000 (equivalent to $18,300 in 2018)
  • {{CAD|1000|1935|round=-2|about=yes}}CA$1,000 (equivalent to about $18,300 in 2018)

Redirects here

See also