Changes
Jump to navigation
Jump to search
;See also * {{tl|Age switch}}
{{Documentation subpage}}
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
== Usage ==
This template is intended to be used by other templates. It returns a "1" if the current time, as interpreted by <nowiki>{{#time: {{{format string|U}}} }}</nowiki> exactly matches any of the supplied times in the parameters {{para|at1}}, {{para|at2}}, and so on. Otherwise it returns a "0".
This is useful for recurring events, such as holidays, hours of the day, etc.
;Parameters:
* {{para|format string|U}} Format string to pass to <nowiki>{{#time:}}</nowiki>.
* {{para|at1}}, {{para|at2}}, etc. - strings to match
* {{para|debug}} - If set, then {{para|format string}} is printed. For debugging.
;Common ''format string'' parameter values. See [[:mw:Help:Extension:ParserFunctions#.23time]] for further information.
:* {{para|format string|M}} - 2-digit month of year. Returns 01 during January
:* {{para|format string|d}} - 2-digit day of month. Returns 01 on the 1st day of the month.
:* {{para|format string|w}} - Day of week. Returns 0 on Sunday
:* {{para|format string|M-d}} - 2-digit month, hyphen, 2-digit day. Returns 01-01 on January 1.
:* {{para|format string|xmn}} - Month as a number ([[Islamic calendar]]). Returns 1 during [[Muharram]].
:* {{para|format string|xjn}} - Month as number ([[Hebrew calendar]]). Returns 1 during [[Nisan]].
:* {{para|format string|H}} - Hour of the day (UTC).
:* {{para|format string}} Defaults to ''U'', which is "seconds since January 1 1970 00:00:00 UTC." This default is deliberately not useful to discourage the use of this template without specifying a format string.
;Recommended uses
* Displaying messages that only appear on certain, possibly non-consecutive days of the week, month, or year.
* Displaying messages that only appear during certain, possibly non-consecutive hours of the day.
;Demonstration (purge this page to update the result)
* Display whether it is the weekend (Saturday or Sunday) or a weekday (Monday through Friday) in the United States:
*:<nowiki>{{#ifeq: {{Is now|format string=w|at1=0|at2=7}}|1|Enjoy the weekend|Another day, another dollar.}}</nowiki>
*:yields
*:{{#ifeq: {{Is now|format string=w|at1=0|at2=7}}|1|Enjoy the weekend|Another day, another dollar.}}
;Limitations:
* The "switch" from 0 to 1 happens only when the page this template is used on is updated or [[WP:PURGE|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.
* There is a hard-coded limit of 31 {{para|atN}} parameters, but this can be extended at any time.
;See also
* {{tl|Age switch}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:Date-computing templates based on current time|{{PAGENAME}}]]
}}</includeonly>
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
== Usage ==
This template is intended to be used by other templates. It returns a "1" if the current time, as interpreted by <nowiki>{{#time: {{{format string|U}}} }}</nowiki> exactly matches any of the supplied times in the parameters {{para|at1}}, {{para|at2}}, and so on. Otherwise it returns a "0".
This is useful for recurring events, such as holidays, hours of the day, etc.
;Parameters:
* {{para|format string|U}} Format string to pass to <nowiki>{{#time:}}</nowiki>.
* {{para|at1}}, {{para|at2}}, etc. - strings to match
* {{para|debug}} - If set, then {{para|format string}} is printed. For debugging.
;Common ''format string'' parameter values. See [[:mw:Help:Extension:ParserFunctions#.23time]] for further information.
:* {{para|format string|M}} - 2-digit month of year. Returns 01 during January
:* {{para|format string|d}} - 2-digit day of month. Returns 01 on the 1st day of the month.
:* {{para|format string|w}} - Day of week. Returns 0 on Sunday
:* {{para|format string|M-d}} - 2-digit month, hyphen, 2-digit day. Returns 01-01 on January 1.
:* {{para|format string|xmn}} - Month as a number ([[Islamic calendar]]). Returns 1 during [[Muharram]].
:* {{para|format string|xjn}} - Month as number ([[Hebrew calendar]]). Returns 1 during [[Nisan]].
:* {{para|format string|H}} - Hour of the day (UTC).
:* {{para|format string}} Defaults to ''U'', which is "seconds since January 1 1970 00:00:00 UTC." This default is deliberately not useful to discourage the use of this template without specifying a format string.
;Recommended uses
* Displaying messages that only appear on certain, possibly non-consecutive days of the week, month, or year.
* Displaying messages that only appear during certain, possibly non-consecutive hours of the day.
;Demonstration (purge this page to update the result)
* Display whether it is the weekend (Saturday or Sunday) or a weekday (Monday through Friday) in the United States:
*:<nowiki>{{#ifeq: {{Is now|format string=w|at1=0|at2=7}}|1|Enjoy the weekend|Another day, another dollar.}}</nowiki>
*:yields
*:{{#ifeq: {{Is now|format string=w|at1=0|at2=7}}|1|Enjoy the weekend|Another day, another dollar.}}
;Limitations:
* The "switch" from 0 to 1 happens only when the page this template is used on is updated or [[WP:PURGE|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.
* There is a hard-coded limit of 31 {{para|atN}} parameters, but this can be extended at any time.
;See also
* {{tl|Age switch}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:Date-computing templates based on current time|{{PAGENAME}}]]
}}</includeonly>