Jump to content

Template:Countdown: Difference between revisions

From The Petit Planet Wiki
ReisuDesign (talk | contribs)
No edit summary
ReisuDesign (talk | contribs)
No edit summary
Line 1: Line 1:
<includeonly><div class="pp-countdown{{#if:{{{Region|}}}|-{{{Region|}}}}}{{#if:{{{Format|}}}| pp-countdown-format-{{{Format}}}| pp-countdown-format-text}}"><!--
<includeonly><div class="pp-countdown{{#if:{{{Region|}}}|-{{{Region|}}}}}"><!--
-->{{#vardefine:time_start_offset|{{#replace:{{{TimeStartOffset|}}}|UTC|GMT}}}}<!--
-->{{#vardefine:time_start_offset|{{#replace:{{{TimeStartOffset|}}}|UTC|GMT}}}}<!--
-->{{#vardefine:time_end_offset|{{#replace:{{{TimeEndOffset|}}}|UTC|GMT}}}}<!--
-->{{#vardefine:time_end_offset|{{#replace:{{{TimeEndOffset|}}}|UTC|GMT}}}}<!--
-->{{#vardefine:countdown_format|{{{Format|text}}}}}<!--
-->{{#vardefine:countdown_padding|{{{Padding|no}}}}}<!--
-->{{#vardefine:countdown_labels|{{{Labels|short}}}}}<!--
--><div><!--
--><div><!--
-->{{#if:{{{TimeStart|}}}{{{TimeEnd|}}}<!--
-->{{#if:{{{TimeStart|}}}{{{TimeEnd|}}}<!--
Line 10: Line 7:
-->||{{#ifexpr:{{#time:U|{{#time:F d, Y h:i:s A e||en}}}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{#if: {{{TimeStart|}}}|{{{TimeStart}}} {{#var: time_start_offset}} | }}|en}} }}<!--
-->||{{#ifexpr:{{#time:U|{{#time:F d, Y h:i:s A e||en}}}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{#if: {{{TimeStart|}}}|{{{TimeStart}}} {{#var: time_start_offset}} | }}|en}} }}<!--
-->|<!--
-->|<!--
--><span data-end="toggle" data-toggle="next" data-options="no-leading-zeros{{#ifeq:{{{shorthand|yes}}}|yes| short-format}}{{#ifeq:{{{Format|text}}}|colon||}}" data-format="{{{Format|text}}}" data-padding="{{{Padding|no}}}" data-labels="{{{Labels|short}}}" data-day-label="{{{DayLabel|}}}" data-hour-label="{{{HourLabel|}}}" data-minute-label="{{{MinuteLabel|}}}" data-second-label="{{{SecondLabel|}}}" class="countdown hidden" style="display:none;"><!--
--><span
data-end="toggle"
data-toggle="next"
data-options="no-leading-zeros {{#ifeq:{{{shorthand|yes}}}|yes|short-format}}"
data-format="{{{Format|text}}}"
data-padding="{{{Padding|no}}}"
data-labels="{{{Labels|short}}}"
data-day-label="{{{DayLabel|}}}"
data-hour-label="{{{HourLabel|}}}"
data-minute-label="{{{MinuteLabel|}}}"
data-second-label="{{{SecondLabel|}}}"
class="countdown hidden"
style="display:none;"
><!--
   -->{{#if:{{{StartBeforeText|}}}|<span class="countdown-before">{{{StartBeforeText}}}</span>|{{#if:{{{Region|}}}|<span class="countdown-region">({{{Region}}})</span>|}}<!--
   -->{{#if:{{{StartBeforeText|}}}|<span class="countdown-before">{{{StartBeforeText}}}</span>|{{#if:{{{Region|}}}|<span class="countdown-region">({{{Region}}})</span>|}}<!--
   -->{{#ifeq:{{{Format|text}}}|boxes||{{#ifeq:{{{Format|text}}}|colon||{{#if:{{{HideText|}}}|| <span class="countdown-prefix">Starts in:</span>}}}}}}<!--
   --> {{#if:{{{HideText|}}}||<span class="countdown-prefix">Starts in:</span>}}}} <!--
   --><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeStart|}}}|{{{TimeStart}}} {{#var: time_start_offset}}|}}|en}}</span><!--
   --><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeStart|}}}|{{{TimeStart}}} {{#var: time_start_offset}}|}}|en}}</span><!--
   -->{{#if:{{{StartAfterText|}}}|<span class="countdown-after">{{{StartAfterText}}}</span>}}<!--
   -->{{#if:{{{StartAfterText|}}}|<span class="countdown-after">{{{StartAfterText}}}</span>}}<!--
--></span><!--
--></span><!--
--><span style="display:none;" class="hidden"><!--
--><span style="display:none;" class="hidden"><!--
   --><span {{#if:{{{EndText|}}}|data-end="toggle" data-toggle="next"|data-end="remove"}} data-options="no-leading-zeros{{#ifeq:{{{shorthand|yes}}}|yes| short-format}}{{#ifeq:{{{Format|text}}}|colon||}}" data-format="{{{Format|text}}}" data-padding="{{{Padding|no}}}" data-labels="{{{Labels|short}}}" data-day-label="{{{DayLabel|}}}" data-hour-label="{{{HourLabel|}}}" data-minute-label="{{{MinuteLabel|}}}" data-second-label="{{{SecondLabel|}}}" class="countdown hidden" style="display:none;"><!--
   --><span
data-end="{{#if:{{{EndText|}}}|toggle|remove}}"
data-toggle="{{#if:{{{EndText|}}}|next|}}"
data-options="no-leading-zeros {{#ifeq:{{{shorthand|yes}}}|yes|short-format}}"
data-format="{{{Format|text}}}"
data-padding="{{{Padding|no}}}"
data-labels="{{{Labels|short}}}"
data-day-label="{{{DayLabel|}}}"
data-hour-label="{{{HourLabel|}}}"
data-minute-label="{{{MinuteLabel|}}}"
data-second-label="{{{SecondLabel|}}}"
class="countdown hidden"
style="display:none;"
><!--
       -->{{#if:{{{StartedBeforeText|{{{BeforeText|}}}}}}|<span class="countdown-before">{{{StartedBeforeText|{{{BeforeText|}}}}}}</span>|{{#if:{{{Region|}}}|<span class="countdown-region">({{{Region}}})</span>|}}<!--
       -->{{#if:{{{StartedBeforeText|{{{BeforeText|}}}}}}|<span class="countdown-before">{{{StartedBeforeText|{{{BeforeText|}}}}}}</span>|{{#if:{{{Region|}}}|<span class="countdown-region">({{{Region}}})</span>|}}<!--
       -->{{#ifeq:{{{Format|text}}}|boxes||{{#ifeq:{{{Format|text}}}|colon||{{#if:{{{HideText|}}}|| <span class="countdown-prefix">{{{CountdownPrefix|Ends in:}}}</span>}}}}}}<!--
       --> {{#if:{{{HideText|}}}||<span class="countdown-prefix">{{{CountdownPrefix|Ends in:}}}</span>}}}} <!--
       --><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{#var: time_end_offset}}|}}|en}}</span><!--
       --><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{#var: time_end_offset}}|}}|en}}</span><!--
       -->{{#if:{{{StartedAfterText|{{{AfterText|}}}}}}|<span class="countdown-after">{{{StartedAfterText|{{{AfterText|}}}}}}</span>}}<!--
       -->{{#if:{{{StartedAfterText|{{{AfterText|}}}}}}|<span class="countdown-after">{{{StartedAfterText|{{{AfterText|}}}}}}</span>}}<!--
Line 25: Line 48:
   -->{{#if:{{{EndText|}}}|<span class="hidden" style="display:none;">{{{EndText}}}</span>}}<!--
   -->{{#if:{{{EndText|}}}|<span class="hidden" style="display:none;">{{{EndText}}}</span>}}<!--
--></span><!--
--></span><!--
 
 
   fallback for mobile
   fallback for mobile
   -->{{#ifeq:{{{nested|}}}|yes||<span class="nocountdown"><!--
   -->{{#ifeq:{{{nested|}}}|yes||<span class="nocountdown"><!--
Line 35: Line 58:
-->|<!--
-->|<!--
-->{{#ifexpr:{{#time:U|{{#time:F d, Y h:i:s A e||en}}}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{#var: time_end_offset}}|}}|en}}}}|<!--
-->{{#ifexpr:{{#time:U|{{#time:F d, Y h:i:s A e||en}}}}<{{#time:U|{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{#var: time_end_offset}}|}}|en}}}}|<!--
   --><span {{#if:{{{EndText|}}}|data-end="toggle" data-toggle="next"|data-end="remove"}} data-options="no-leading-zeros{{#ifeq:{{{shorthand|yes}}}|yes| short-format}}{{#ifeq:{{{Format|text}}}|colon||}}" data-format="{{{Format|text}}}" data-padding="{{{Padding|no}}}" data-labels="{{{Labels|short}}}" data-day-label="{{{DayLabel|}}}" data-hour-label="{{{HourLabel|}}}" data-minute-label="{{{MinuteLabel|}}}" data-second-label="{{{SecondLabel|}}}" class="countdown hidden" style="display:none;"><!--
   --><span
data-end="{{#if:{{{EndText|}}}|toggle|remove}}"
data-toggle="{{#if:{{{EndText|}}}|next|}}"
data-options="no-leading-zeros {{#ifeq:{{{shorthand|yes}}}|yes|short-format}}"
data-format="{{{Format|text}}}"
data-padding="{{{Padding|no}}}"
data-labels="{{{Labels|short}}}"
data-day-label="{{{DayLabel|}}}"
data-hour-label="{{{HourLabel|}}}"
data-minute-label="{{{MinuteLabel|}}}"
data-second-label="{{{SecondLabel|}}}"
class="countdown hidden"
style="display:none;"
><!--
       -->{{#if:{{{StartedBeforeText|{{{BeforeText|}}}}}}|<span class="countdown-before">{{{StartedBeforeText|{{{BeforeText|}}}}}}</span>|{{#if:{{{Region|}}}|<span class="countdown-region">({{{Region}}})</span>|}}<!--
       -->{{#if:{{{StartedBeforeText|{{{BeforeText|}}}}}}|<span class="countdown-before">{{{StartedBeforeText|{{{BeforeText|}}}}}}</span>|{{#if:{{{Region|}}}|<span class="countdown-region">({{{Region}}})</span>|}}<!--
       -->{{#ifeq:{{{Format|text}}}|boxes||{{#ifeq:{{{Format|text}}}|colon||{{#if:{{{HideText|}}}|| <span class="countdown-prefix">{{{CountdownPrefix|Ends in:}}}</span>}}}}}}<!--
       --> {{#if:{{{HideText|}}}||<span class="countdown-prefix">{{{CountdownPrefix|Ends in:}}}</span>}}}} <!--
       --><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{#var: time_end_offset}}|}}|en}}</span><!--
       --><span class="countdowndate" style="font-weight:bold">{{#time:F d, Y h:i:s A e|{{#if:{{{TimeEnd|}}}|{{{TimeEnd}}} {{#var: time_end_offset}}|}}|en}}</span><!--
       -->{{#if:{{{StartedAfterText|{{{AfterText|}}}}}}|<span class="countdown-after">{{{StartedAfterText|{{{AfterText|}}}}}}</span>}}<!--
       -->{{#if:{{{StartedAfterText|{{{AfterText|}}}}}}|<span class="countdown-after">{{{StartedAfterText|{{{AfterText|}}}}}}</span>}}<!--
   --></span><!--
   --></span><!--
   -->{{#if:{{{EndText|}}}|<span class="hidden" style="display:none;">{{{EndText}}}</span>}}<!--
   -->{{#if:{{{EndText|}}}|<span class="hidden" style="display:none;">{{{EndText}}}</span>}}<!--
 
 
   fallback for mobile
   fallback for mobile
   -->{{#ifeq:{{{nested|}}}|yes||<span class="nocountdown"><!--
   -->{{#ifeq:{{{nested|}}}|yes||<span class="nocountdown"><!--

Revision as of 00:09, 19 September 2026

Template documentation
Note: parts of or the entire template might not be visible without values provided.
This template uses JS found at MediaWiki:Gadget-Countdown.js.

Parameters

Template for displaying a countdown

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
RegionRegion

The region the countdown is for

Example
NA
Unknownsuggested
Start OffsetTimeStartOffset

The offset for the start time

Example
UTC+8
Unknownsuggested
End OffsetTimeEndOffset

The offset for the end time

Example
UTC+8
Unknownsuggested
Start TimeTimeStart

The time the event starts, formatted as a date

Example
1970-01-01 00:00:00
Unknownsuggested
End TimeTimeEnd

The time the event ends, formatted as a date

Example
1970-01-02 00:00:00
Unknownrequired
Hide TextHideText

Whether to hide the "ends in" text

Unknownsuggested
End TextEndText

The text to display when the event ends

Unknownsuggested
Countdown PrefixCountdownPrefix

The prefix to use for the end countdown instead of "Ends in:"

Unknownsuggested

Examples

Case: Offset

{{Countdown
|Region=AS
|EventName=Offset1
|TimeStart=2024/01/15 23:00:00
|TimeStartOffset=GMT+8
|TimeEnd=2050/01/31 03:59:59
|TimeEndOffset=GMT+8
}}
(AS) Ends in: 8496d 3h 46m 16s (Update)

Case: Upcoming

{{Countdown
|Region=AS
|EventName=TemplateExample1
|TimeStart=2050/01/15 23:00:00 GMT+8
|TimeEnd=2025/01/31 03:59:59 GMT+8
}}
(AS) Starts in: 8480d 22h 46m 17s (Update)

Case: Started

{{Countdown
|Region=AS
|EventName=TemplateExample2
|TimeStart=2021-01-8 10:00:00 GMT+8
|TimeEnd=2050-01-31 03:59:59 GMT+8
}}
(AS) Ends in: 8496d 3h 46m 16s (Update)

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
}}
(AS) Ends in: 8496d 3h 46m 16s (Update)

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=
}}
(AS) Starts in: 8496d 3h 46m 16s (Update)

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=2050/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.

  • 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 20, 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 4, 2018 06:00, the syntax automatically assumes UTC.