Difference between revisions of "Template:Counter"

From CWCki
Jump to navigation Jump to search
(Created page with "<includeonly>{{formatnum:{{#ifexpr:{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}} > {{{2|0}}}|{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}}|{{{2...")
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{formatnum:{{#ifexpr:{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}} > {{{2|0}}}|{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}}|{{{2}}}}}}} days</includeonly><noinclude>{{clear}}
<includeonly>{{formatnum:{{#ifexpr:{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}} > {{{2|0}}}<!--
This template automates the streak count: if the current streak breaks the record, this template will handle this for you.
-->|{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}}{{#if:{{{big|}}}||&nbsp;day{{#ifeq:{{#expr:({{#time:U|now}}-{{#time:U|{{{1}}}}})/86400 round 0}}|1||s}}}}<!--
-->|{{{2|0}}}{{#if:{{{big|}}}||&nbsp;day{{#ifeq:{{{2|}}}|1||s}}}}}}}}</includeonly><noinclude>{{clear}}
This template automates the big counter and the previous streak: if the current streak breaks the record, this template will handle this for you.


For use in both [[Template:Begging Counter|Begging]] and [[Template:Coping Counter|Coping]] counters.
For use in both [[Template:Begging Counter|Begging]] and [[Template:Coping Counter|Coping]] counters.
Line 10: Line 12:
! Input
! Input
! Output
! Output
|-
| Chris last did something on {{#time:j F Y|now - 2 months}} (for the big counter).
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now - 2 months}}<nowiki>|big=yes}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now - 2 months}}|big=yes}}
|-
|-
| Chris last did something on {{#time:j F Y|now - 2 months}}.
| Chris last did something on {{#time:j F Y|now - 2 months}}.
Line 15: Line 21:
| {{Counter|{{#time:Y-m-d H:00:00|now - 2 months}}}}
| {{Counter|{{#time:Y-m-d H:00:00|now - 2 months}}}}
|-
|-
| Chris last did something on {{#time:j F Y|now - 1 month}}, and the previous streak was 15 days ago.
| Chris last did something on {{#time:j F Y|now - 1 month}}, and the longest streak was 15 days.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now - 1 month}}<nowiki>|15}}</nowiki></code>
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now - 1 month}}<nowiki>|15}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now - 1 month}}|15}}
| {{Counter|{{#time:Y-m-d H:00:00|now - 1 month}}|15}}
|-
|-
| Chris last did something on {{#time:j F Y|now}}, and the previous streak was 15 days ago.
| Chris last did something on {{#time:j F Y|now}}, and the longest streak was 15 days.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now}}<nowiki>|15}}</nowiki></code>
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now}}<nowiki>|15}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now}}|16}}
| {{Counter|{{#time:Y-m-d H:00:00|now}}|15}}
|-
| Chris last did something on {{#time:j F Y|now}}, and the longest streak was one day.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now}}<nowiki>|1}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now}}|1}}
|-
| Chris last did something yesterday, and the longest streak was not recorded.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now - 1 day}}<nowiki>|0}}</nowiki></code> or<br/><code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now - 1 day}}<nowiki>}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now - 1 day}}}}
|-
| Chris last did something just now, and the longest streak was not recorded.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now}}<nowiki>|0}}</nowiki></code> or<br/><code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now}}<nowiki>}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now}}|0}}
|}
|}
[[Category:Front page templates]]</noinclude>
[[Category:Front page templates]]</noinclude>

Latest revision as of 02:35, 25 July 2021

This template automates the big counter and the previous streak: if the current streak breaks the record, this template will handle this for you.

For use in both Begging and Coping counters.

Examples

Scenario Input Output
Chris last did something on 21 September 2024 (for the big counter). {{Counter|2024-09-21 12:00:00|big=yes}} 61
Chris last did something on 21 September 2024. {{Counter|2024-09-21 12:00:00}} 61 days
Chris last did something on 21 October 2024, and the longest streak was 15 days. {{Counter|2024-10-21 12:00:00|15}} 31 days
Chris last did something on 21 November 2024, and the longest streak was 15 days. {{Counter|2024-11-21 12:00:00|15}} 15 days
Chris last did something on 21 November 2024, and the longest streak was one day. {{Counter|2024-11-21 12:00:00|1}} 1 day
Chris last did something yesterday, and the longest streak was not recorded. {{Counter|2024-11-20 12:00:00|0}} or
{{Counter|2024-11-20 12:00:00}}
1 day
Chris last did something just now, and the longest streak was not recorded. {{Counter|2024-11-21 12:00:00|0}} or
{{Counter|2024-11-21 12:00:00}}
0 days