Difference between revisions of "Template:Age switch"
(Creation (as this is needed)) |
m (Text replacement - "{{/doc}}" to "{{Documentation}}") |
||
Line 1: | Line 1: | ||
{{#iferror:{{#time:U|{{{d}}} }}|-1|{{#ifexpr:{{#time:U|{{{d}}} }}<={{#time:U|{{CURRENTTIMESTAMP}}-{{#if:{{{age|}}}|<!-- The following #iferror: retains compatibility for previous code -->{{#iferror:{{#time:U|{{{age|}}} }}|{{{age|}}} seconds|{{{age|}}} }}|604800 seconds}} }}|1|0}}}}<!-- | {{#iferror:{{#time:U|{{{d}}} }}|-1|{{#ifexpr:{{#time:U|{{{d}}} }}<={{#time:U|{{CURRENTTIMESTAMP}}-{{#if:{{{age|}}}|<!-- The following #iferror: retains compatibility for previous code -->{{#iferror:{{#time:U|{{{age|}}} }}|{{{age|}}} seconds|{{{age|}}} }}|604800 seconds}} }}|1|0}}}}<!-- | ||
--><noinclude> | --><noinclude> | ||
− | {{ | + | {{Documentation}} |
<!-- Add categories to the /doc subpage, please, not here! --> | <!-- Add categories to the /doc subpage, please, not here! --> | ||
</noinclude> | </noinclude> |
Latest revision as of 16:18, 2 March 2023
-1
Usage[edit]
This template is intended to be used by other templates. It returns a "0" if the "age," with respect to "d," has not been reached or a "1" if it has. Returns "-1" if "d" is not a valid date.
It is useful for countdown timers.
- Parameters
|d=
is the date the clock "starts" at|age=
is the age at which the result will change from 0 to 1. (optional, default is 1 week)
- Limitations
- The "switch" from 0 to 1 happens only when the page this template is used on is updated or purged. If a page includes a template which calls this template, it is the page the reader sees, not the template which calls this template, which must be purged or updated.
- See also
- {{Is now}}
- {{Compare dates}}