Main Page

Difference between revisions of "Template:Countdown"

From Arks-Visiphone
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><div>{{#ifexpr:{{#time:U|now+9 hours}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{{TimeStart|Now}}}}}}}|Time Until Start: <span data-options="no-leading-zeros short-format" data-end="toggle" data-toggle=".post-countdown1{{{EventName}}}" class="countdown" style="display:none;"><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{{TimeStart}}}}}</span></span><span class="post-countdown1{{{EventName}}}" style="display:none;">Event has started. <small>[{{fullurl:{{FULLPAGENAME}}|action=purge}} Purge page]</small></span>|Time Remaining: <span data-options="no-leading-zeros short-format" data-end="toggle" data-toggle=".post-countdown2{{{EventName}}}" class="countdown" style="display:none;"><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{{TimeEnd}}}}}</span></span><span class="post-countdown2{{{EventName}}}" style="display:none;">Event has concluded. <small>[{{fullurl:{{FULLPAGENAME}}|action=purge}} Purge page]</small></span>}}</div></includeonly>
+
<includeonly><div class="hidden"><!--
<noinclude>(Countdown) - Parses EventName, TimeStart and TimeEnd into a countdown, mostly used on event mentioning pages.
+
-->{{#if:{{{TimeStart|}}}{{{TimeEnd|}}}<!--
 
+
-->|{{#iferror:{{#ifexpr:{{#time:U|{{{TimeStart|}}} {{{Offset|{{{TimeStartOffset|}}}}}}}}<{{#time:U|{{{TimeEnd|}}} {{{Offset|{{{TimeEndOffset|}}}}}}}}}}<!--
This template works with a JavaScript snippet that can be found either in this wiki's common.js or a gadget. It does NOT use the countdown extension.
+
-->||{{#ifexpr:{{#time:U|{{#time:F d, Y h:i:s A e|}}}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{#if:{{{TimeStart|}}}|{{{TimeStart}}} {{{Offset|{{{TimeStartOffset|}}}}}}|}}}}}}<!--
 
+
-->|{{#if:{{{Region|}}}|({{{Region}}})|}} Starts in: <!--
Example Usage:
+
--><span data-end="toggle" data-toggle="next" data-options="no-leading-zeros short-format" class="countdown" style="display:none;"><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeStart|}}}|{{{TimeStart}}} {{{Offset|{{{TimeStartOffset|}}}}}}|}}}}</span></span><!--
<pre>
+
--><span style="display:none;">Event has started. <small>[{{fullurl:{{FULLPAGENAME}}|action=purge}} Purge page]</small></span><!--
{{Countdown
+
-->|{{#ifexpr:{{#time:U|{{#time:F d, Y h:i:s A e|}}}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{{Offset|{{{TimeEndOffset|}}}}}}|}}}}}}|{{#if:{{{Region|}}}|({{{Region}}})|}} Ends in: <!--
|EventName=SecretPhraseMay15th2020
+
--><span data-end="toggle" data-toggle="next" data-options="no-leading-zeros short-format" class="countdown" style="display:none;"><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{{Offset|{{{TimeEndOffset|}}}}}}|}}}}</span></span><!--
|TimeStart=May 15 2020 15:00 +0900
+
--><span style="display:none;">Event has concluded. <small>[{{fullurl:{{FULLPAGENAME}}|action=purge}} Purge page]</small></span>|}}<!--
|TimeEnd=June 4 2020 23:59 +0900
+
-->}}<!--
}}
+
-->}}<!--
</pre>
+
-->|}}<!--
 
+
--></div></includeonly><!--
Example Output:
+
--><noinclude>{{documentation}}</noinclude>
{{Countdown
 
|EventName=SecretPhraseMay15th2020
 
|TimeStart=May 15 2020 15:00 +0900
 
|TimeEnd=June 4 2020 23:59 +0900
 
}}
 
 
 
*Each EventName must be unique, or the countdown end message will display for all countdowns once one TimeEnd is reached.
 
*When TimeStart has been reached, the countdown will show "Event has started" and provide a link to purge the page (the user can alternatively refresh).
 
*If |TimeStart is not included in the template call, the template will automatically use Now as a placeholder time, and will skip the Time Until Start portion and go into the Time remaining portion.
 
[[Category:Templates]]</noinclude>
 

Latest revision as of 15:33, 27 January 2021

[edit] [purge] Template documentation
Main article: Template:Countdownall

Parameters

Parameter Description
Region (Optional) Region to be stated next to the countdown.
Offset (Optional) Offset is a special parameter (usually timezone, e.g. GMT+8) that must be used if you are an author of templates incorporating countdown and are parsing one input into multiple timezone outputs, in that case, do not forcefeed an offset by hand into the template and use this parameter instead. This is because if there are some users that leave blank inputs, those blanks will be combined with your forcefed offset to form midnight + your offset.
EventName Event name, must be unique, or the countdown end message will display for all countdowns once one TimeEnd is reached.
  • If unsure, {{PAGENAME}} is suggested.
TimeStart Start date and time, accepts all formats except those that contain fullstops.
  • If not included, will jump straight into "Ends in: Time Remaining" by assuming the start time is now.
  • When not reached, the countdown will show "Starts in:"
  • When TimeStart has been reached, the countdown will show "Event has started".
  • When ongoing, the countdown will show "Ends in:"
  • When TimeEnd has been reached, the countdown will show "Event has concluded."
  • Any invalid dates, blanks, or long past TimeEnd dates will not show the countdown and will be a blank space instead.
TimeEnd End date and time, accepts all formats except those that contain fullstops.

Examples

Case: Offset

{{Countdown
|Region=AS
|EventName=Offset1
|TimeStart=2024/01/15 23:00:00
|TimeEnd=2025/01/31 03:59:59
|Offset=GMT+8
}}

Case: Upcoming

{{Countdown
|Region=AS
|EventName=TemplateExample1
|TimeStart=2025/01/15 23:00:00 GMT+8
|TimeEnd=2025/01/31 03:59:59 GMT+8
}}

Case: Started

{{Countdown
|Region=AS
|EventName=TemplateExample2
|TimeStart=2021-01-8 10:00:00 GMT+8
|TimeEnd=2025-01-31 03:59:59 GMT+8
}}

Case: Long Ended

{{Countdown
|Region=AS
|EventName=TemplateExample3
|TimeStart=2020-01-16 10:00:00 GMT+8
|TimeEnd=2020-01-31 03:59:59 GMT+8
}}

Case: Blank Start

{{Countdown
|Region=AS
|EventName=TemplateExample4
|TimeStart=
|TimeEnd=2025-01-31 03:59:59 GMT+8
}}

Case: Blank Start Ended

{{Countdown
|Region=AS
|EventName=TemplateExample4
|TimeStart=
|TimeEnd=2020-01-31 03:59:59 GMT+8
}}

Case: Blank End

{{Countdown
|Region=AS
|EventName=TemplateExample5
|TimeStart=2025-01-31 03:59:59 GMT+8
|TimeEnd=
}}

Case: Blank End Started

{{Countdown
|Region=AS
|EventName=TemplateExample5
|TimeStart=2020-01-31 03:59:59 GMT+8
|TimeEnd=
}}

Case: Invalid Start

{{Countdown
|Region=AS
|EventName=TemplateExample6
|TimeStart=aaaaaaaaaaaa
|TimeEnd=2025/01/31 03:59:59 GMT+8
}}

Case: Invalid End

{{Countdown
|Region=AS
|EventName=TemplateExample7
|TimeStart=2025/01/16 10:00:00 GMT+8
|TimeEnd=aaaaaaaaaaaa
}}

Case: Invalid Start End

{{Countdown
|Region=AS
|EventName=TemplateExample8
|TimeStart=aaaaaaaaaaaa
|TimeEnd=aaaaaaaaaaaa
}}

Case: Blank

{{Countdown
|Region=AS
|EventName=TemplateExample9
|TimeStart=
|TimeEnd=
}}

General Info

(Countdown) - Parses EventName, TimeStart and TimeEnd into a countdown, mostly used on event mentioning pages.

  • This template works with a JavaScript snippet imported from the developer's wiki into this wiki's MediaWiki:ImportJS. It does NOT use the countdown extension.
  • Utilizes the parser functions {{#time:F d, Y h:i:s A e|}} and {{#time:F d, Y|}} and is thus able to accept a variety of formats which are parsed and stored internally as UTC.
  • The following are accepted: backslashes (2019/1/1), dashes (2019-1-1), most manner of timezones (+9, +9 hours. +0930, JST, GMT +9) and commas in the correct spacing (November 20th, 2019).
  • The following are not accepted and will throw errors: any dots as they cause non integer values, including dot spacing (2019.1.1) and specifying timezones in non integer (+9.5).
  • If no timezone is specified e.g. October 04, 2018 06:00, the syntax automatically assumes UTC.