Help:Counter

From RationalWiki
Jump to navigation Jump to search

We can make counters!

How many years since 2000? Counter[edit]

It's has been 24 years since 2000.

This counter is really basic, we get the current year using the magic word: {{CURRENTYEAR}} than we minus the {{CURRENTYEAR}} from 2000.

{{#expr:{{CURRENTYEAR}} - 2000}}

When is the year going to end? Counter[edit]

Ok. This timer tells when the year is going to end in months.

It's one month till the end of the year.

Let's break down how it works.

We have to get the current month.

{{#time: m|now}}

which we will compare to last month. There are 12 months in a year.

{{#ifeq:foo|bar|result if foo = boo|result if foo ≠ bar}}

<!--Therefore we do this: -->

{{#ifeq:{{#time: m|now}}|12|result if current month is December|result if current month is not December}}

<!--If it's true we want it to say "It's the last month of the year!" and if it's false we want the number of months left in the year. -->

{{#ifeq:{{#time: m|now}}|12|It's the last month of the year!|result if false}}

That is the barebones of our new counter! Now to move on the calculating the month left.

{{#expr:12 - {{#time: m|now}}}}

results in: 1. Now we have a way to know that there are 1 month(s) left in the year of 2024. Add more flavoring text:

It's {{#expr:12 - {{#time: m|now}}}} months till the end of the year.

and we get this: It's 1 months till the end of the year.

What what of English grammar rules. What if the month is November? "It's 1 months till the end of the year" doesn't sound correct.

{{#switch: (current month)
 | 11 = result if current month is 11
 | 12 = if current month is 12
 | #default = if current month is not 12 or 11
}}

<!-- Add the magic words in: -->

{{#switch: {{#time: m|now}}
 | 11 = It's one month till the end of the year.
 | 12 = It's the last month of the year!
 | #default = {{#time: m|now}} months till the end of the year.
}}


With more added styling, we get our counter:

It's one month till the end of the year.

See also[edit]