Difference between revisions of "Template:CAD/doc"

From blackwiki
Jump to navigation Jump to search
imported>Ivanvector
(→‎Inflation calculation: correcting description for examples that follow)
imported>Djr13
(copy documentation style from Template:US$)
Line 2: Line 2:
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
  
This template adds the currency mark "CAD" optionally linked to the [[Canadian dollar]] article.
+
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. <em>See warnings below.</em>
  
=== Usage ===
+
== Usage ==
{{tlx|CAD|''value''}}
+
{{tlxi|CA$|value}}
  
*''value'' must be specified.
+
Example:
 +
* {{tld|CA$}} → {{CA$}}
 +
* {{tld|CA$|123.45}} → {{CA$|123.45}}
 +
 
 +
=== Link ===
 +
The parameter {{para|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:
 +
* {{tld|CA$|123.45|3=link=yes}} → {{CA$|123.45|link=yes}}
 +
 
 +
=== Inflation calculation ===
 +
{{ombox |type= content |imageright= [[File:Emblem-money.svg|42px]] |text= This template is <strong>only capable</strong> of inflating Consumer Price Index values: staples, workers' rent, small service bills (doctor's costs, train tickets). This template is <strong>incapable</strong> of inflating capital expenses, government expenses, or the personal wealth and expenditure of the rich. <strong>Incorrect use of this template would constitute original research. If you yourself do not have economic training, then please consult someone who does before using this template.</strong>}}
 +
{{ombox |type= content |imageright= [[File:Current event warning.svg|42px]] |text= <strong>Do not assume that using this template will mean that a calculated value is <em>"current"</em></strong>, <em>"as of {{CURRENTYEAR}}"</em>, <em>"as of {{#expr:{{CURRENTYEAR}}-1}}"</em> or even necessarily <em>"recent"</em>. Do not use <code><nowiki>{{CURRENTYEAR}}</nowiki></code> to refer to calculated value, instead {{tlx|Inflation-year|CA}} may be used. See also [[MOS:REALTIME]].}}
  
<nowiki>{{CAD|123.45}}</nowiki> produces CAD 123.45 (with a space between CAD and the value).
+
The template supports inflation calculation, by way of {{tlx|Inflation}}. If the second parameter is used, to specify a year, and this year is within a certain range of available inflation data (specifically, {{nowrap|if {{Inflation/CA/startyear}} ≤ <code>{{var|year}}</code> < {{Inflation-year|CA}}}}), the equivalent value represented in {{Inflation-year|CA}} dollars will be calculated in parentheses. However, this function should only be used in appropriate situations.
  
==== Inflation calculation ====
+
* {{tlxi|CA$|value|year}}
The template now supports calculation of inflation. A second parameter can be used to specify a year between 1913 and 2009 and will calculate the relative value today.
+
* {{tlx|CA$|{{var|value}}|{{var|year}}|4=round={{var|round}}|5=about=yes}}
{{tlx|CAD|''value''|''year''}}
 
A third parameter <tt>round</tt> will cause the template to calculate to the indicated number of decimal places instead of the nearest cent. This can be activated by typing <tt>round=<number of digits></tt>.
 
  
 
Examples:
 
Examples:
*{{tlx|CAD|10|1935}} → {{CAD|10|1935}}
+
* {{tld|CA$|100|{{#expr:{{Inflation/CA/startyear}}-1}}}} → {{CA$|100|{{#expr:{{Inflation/CA/startyear}}-1}}}}
*{{tlx|CAD|10|1935|4=round=0}} → {{CAD|10|1935|round=0}}
+
* {{tld|CA$|100|{{Inflation/CA/startyear}}}} → {{CA$|100|{{Inflation/CA/startyear}}}}
*{{tlx|CAD|1000|1935|4=round=2}} → {{CAD|1000|1935|round=2}}
+
* {{tld|CA$|100|1966}} → {{CA$|100|1966}}
*{{tlx|CAD|1000|1935|4=round=-2}} → {{CAD|1000|1935|round=-2}}
+
* {{tld|CA$|100|1966|4=link=yes}} → {{CA$|100|1966|link=yes}}
 +
* {{tld|CA$|100|{{#expr:{{Inflation-year|CA}}-1}}}} → {{CA$|100|{{#expr:{{Inflation-year|CA}}-1}}}}
 +
* {{tld|CA$|100|{{Inflation-year|CA}}}} → {{CA$|100|{{Inflation-year|CA}}}}
 +
* {{tld|CA$|100|{{CURRENTYEAR}}}} → {{CA$|100|{{CURRENTYEAR}}}}
 +
* {{tld|CA$|100|{{#expr:{{CURRENTYEAR}}+1}}}} → {{CA$|100|{{#expr:{{CURRENTYEAR}}+1}}}}
 +
 
 +
Additional parameter {{para|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 {{para|round|{{var|integer}}}}. These parameters may be combined.
  
==== Link ====
+
Examples:
The ''link'' parameter may be used to link CAD 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.
+
* {{tld|CA$|10|1935}} → {{CA$|10|1935}}
 +
* {{tld|CA$|10|1935|4=round=0}} → {{CA$|10|1935|round=0}}
 +
* {{tld|CA$|10|1935|4=about=yes}} → {{CA$|10|1935|about=yes}}
 +
* {{tld|CA$|1000|1935|4=round=2}} → {{CA$|1000|1935|round=2}}
 +
* {{tld|CA$|1000|1935|4=round=-2}} → {{CA$|1000|1935|round=-2}}
 +
* {{tld|CA$|1000|1935|4=round=-2|5=about=yes}} → {{CA$|1000|1935|round=-2|about=yes}}
  
Example:
+
== Redirects here ==
*{{tlx|CAD|10|1935|4=link=yes}} → {{CAD|10|1935|link=yes}}
+
* [[Template:CA$]]
  
=== See also ===
+
== See also ==
 
* [[Wikipedia:Manual of Style (dates and numbers)#Currencies]]
 
* [[Wikipedia:Manual of Style (dates and numbers)#Currencies]]
 
* [[Wikipedia:Canadian Wikipedians' notice board/Style guide#Currency]]
 
* [[Wikipedia:Canadian Wikipedians' notice board/Style guide#Currency]]
 +
* [[Template:AUD]]
 +
* [[Template:US$]]
  
 
<includeonly>
 
<includeonly>
 
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
 
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
{{DEFAULTSORT:Cad}}  
+
{{DEFAULTSORT:CAD}}
 +
[[Category:Canada templates]]
 
[[Category:Currency templates]]
 
[[Category:Currency templates]]
[[Category:Canada templates]]
+
[[Category:Currencies of Canada|τ]]
[[Category:Currencies of Canada|*]]
 
 
</includeonly>
 
</includeonly>

Revision as of 09:43, 15 March 2016

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

{{CA$|value}}

Example:

  • {{CA$}}CA$
  • {{CA$|123.45}}CA$123.45

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:

  • {{CA$|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.

  • {{CA$|value|year}}
  • {{CA$|value|year|round=round|about=yes}}

Examples:

  • {{CA$|100|1913}}CA$100
  • {{CA$|100|1914}}CA$100 (equivalent to $2,223 in 2018)
  • {{CA$|100|1966}}CA$100 (equivalent to $762.29 in 2018)
  • {{CA$|100|1966|link=yes}}CA$100 (equivalent to $762.29 in 2018)
  • {{CA$|100|2017}}CA$100 (equivalent to $102.3 in 2018)
  • {{CA$|100|2018}}CA$100
  • {{CA$|100|2026}}CA$100
  • {{CA$|100|2027}}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:

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

Redirects here

See also