Difference between revisions of "Template:Counter"

From CWCki
Jump to navigation Jump to search
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|0}}}}}}}{{#if:{{{big|}}}||&nbsp;days}}</includeonly><noinclude>{{clear}}
<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}}{{#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.
This template automates the big counter and the previous streak: if the current streak breaks the record, this template will handle this for you.


Line 25: Line 27:
| 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 previous streak was 15 days ago.
| <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 previous streak was 1 day ago.
| <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 on {{#time:j F Y|now - 1 day}}, and the previous streak was not recorded.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now - 1 day}}<nowiki>|0}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now - 1 day}}|0}}
|-
| Chris last did something just now, and the previous streak was not recorded.
| <code><nowiki>{{Counter|</nowiki>{{#time:Y-m-d H:00:00|now}}<nowiki>|0}}</nowiki></code>
| {{Counter|{{#time:Y-m-d H:00:00|now}}|0}}
|}
|}
[[Category:Front page templates]]</noinclude>
[[Category:Front page templates]]</noinclude>

Revision as of 03:19, 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 7 March 2024 (for the big counter). {{Counter|2024-03-07 09:00:00|big=yes}} 61
Chris last did something on 7 March 2024. {{Counter|2024-03-07 09:00:00}} 61 days
Chris last did something on 7 April 2024, and the previous streak was 15 days ago. {{Counter|2024-04-07 09:00:00|15}} 30 days
Chris last did something on 7 May 2024, and the previous streak was 15 days ago. {{Counter|2024-05-07 09:00:00|15}} 15 days
Chris last did something on 7 May 2024, and the previous streak was 1 day ago. {{Counter|2024-05-07 09:00:00|1}} 1 day
Chris last did something on 6 May 2024, and the previous streak was not recorded. {{Counter|2024-05-06 09:00:00|0}} 1 day
Chris last did something just now, and the previous streak was not recorded. {{Counter|2024-05-07 09:00:00|0}} 0 days