Difference between revisions of "Template:Countdown"

From blackwiki
Jump to navigation Jump to search
imported>Technical 13
(Okay, so this part now works based on development done in the sandbox and the associated Template:Countdown/testcases.)
imported>Technical 13
m (Make this template work inline... Still working on expanding the counter out past "weeks" to include months and years in the sandbox.)
Line 1: Line 1:
<includeonly>{{#ifexpr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}{{#switch:{{lc:{{{duration unit|seconds}}}}}|years|y|year=+({{{duration|0}}}*(60*60*24*365.25))|months|n|m|f|xg|month=+({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}} +{{{duration|0}}} months}}-{{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}})|weeks|w|week=+({{{duration|0}}}*(60*60*24*7))|days|j|d|z|day=+({{{duration|0}}}*(60*60*24))|hours|g|h|hour=+({{{duration|0}}}*(60*60))|minutes|i|minute=+({{{duration|0}}}*(60))|#default=+{{{duration|0}}}}})<{{#time:U}}|{{{eventend|{{{event|The event}}} has already ended.}}}|{{#ifexpr:{{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}} }}>{{#time:U}}|{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7)) = 0||{{{event prefix|There are{{sp}}}}}'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))}}</span>''' week{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))}}||s}}{{sp}}}}{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))*7) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))*7)}}</span>''' day{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))*7)}}||s}}{{sp}}}}{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))*24) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))*24)}}</span>''' hour{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))*24)}}||s}}{{sp}}}}{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))*60) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))*60)}}</span>''' minute{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))*60)}}||s}}{{sp}}}}{{#ifexpr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)*60) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)*60)}}</span>''' second{{plural:{{#expr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)*60)}}||s}}{{sp}}}}left before {{{event|the event.}}}|{{{eventstart|{{{event|The event}}} has already started.}}}}}}}<small>({{purge|refresh}})</small>
+
<includeonly>{{#ifexpr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}{{#switch:{{lc:{{{duration unit|seconds}}}}}|years|y|year=+({{{duration|0}}}*(60*60*24*365.25))|months|n|m|f|xg|month=+({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}} +{{{duration|0}}} months}}-{{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}})|weeks|w|week=+({{{duration|0}}}*(60*60*24*7))|days|j|d|z|day=+({{{duration|0}}}*(60*60*24))|hours|g|h|hour=+({{{duration|0}}}*(60*60))|minutes|i|minute=+({{{duration|0}}}*(60))|#default=+{{{duration|0}}}}})<{{#time:U}}|{{{eventend|{{{event|The event}}} has already ended.}}}|{{#ifexpr:{{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}} }}>{{#time:U}}|{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7)) = 0||{{{event prefix|There are{{sp}}}}}'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))}}</span>''' week{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))}}||s}}{{sp}}}}{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))*7) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))*7)}}</span>''' day{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24*7))*7)}}||s}}{{sp}}}}{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))*24) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))*24)}}</span>''' hour{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60*24))*24)}}||s}}{{sp}}}}{{#ifexpr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))*60) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))*60)}}</span>''' minute{{plural:{{#expr:floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}}  {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/(60*60))*60)}}||s}}{{sp}}}}{{#ifexpr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)*60) = 0||'''<span style="color: {{{color|#F00}}};">{{#expr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)*60)}}</span>''' second{{plural:{{#expr:({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})-(floor(({{#time:U|{{{year|1970}}}-{{{month|1}}}-{{{day|1}}} {{{hour|00}}}:{{{minute|00}}}:{{{second|00}}}}}-{{#time:U}})/60)*60)}}||s}}{{sp}}}}left before {{{event|the event.}}}|{{{eventstart|{{{event|The event}}} has already started.}}}}}}}<small>({{purge|refresh}})</small></includeonly><noinclude>
</includeonly><noinclude>
 
 
{{countdown
 
{{countdown
 
  |year      = 9999
 
  |year      = 9999

Revision as of 15:49, 20 September 2013

There areTemplate:Sp416008 weeksTemplate:Sp4 daysTemplate:Sp4 hoursTemplate:Sp46 minutesTemplate:Sp50 secondsTemplate:Spleft before 1-1-9999 starts(Script error: No such module "Purge".)

Template documentation[view] [edit] [history] [purge]

Notes

Please note the following important points before using this template.

The time on this countdown clock is GMT (UTC+0)

  • if the event is held in more than a year, the number of years and everything below will be shown
  • if the event is held in more than a week, the number of weeks and everything below will be shown
  • if the event is held in more than 24 hours, the number of days and everything below will be shown
  • if the event is held within 24 hours, the number of hours left and everything below will be shown
  • if the event is held within 1 hour, the number of minutes left and the number of seconds left will be shown
  • if the event is held within 1 minute, the number of seconds left will be shown

Duration is in seconds, so duration=3600 for a one-hour event. Alternatively, duration and duration unit=//unit// can be used in unison (e.g., duration=1|duration unit=year).

This template should not be used in articles per MOS:TIME and MOS:DATED.

Usage

Editors can use this template as a countdown clock for a lot of different events. The following can show you how to use this template.

Simple Countdown Clock

This type of countdown clock is suitable for events with no duration.

{{countdown
 |year  = 2020
 |month = 04
 |day   = 15
 |event = Branch Network Awards Night
}}

If you type in the above, something like the following will appear.

Branch Network Awards Night has already ended.(Script error: No such module "Purge".)

Advanced Countdown Clock

This type of countdown clock is suitable for events with a duration.

{{countdown
 |year       = 2022
 |month      = 4
 |day        = 15
 |hour       = 19
 |minute     = 40
 |second     = 0
 |event      = 
 |duration   = 21
 |eventstart = unknown has started
 |eventend   = unknown has ended
}}

If you type in the above, something like the following will appear.

unknown has ended(Script error: No such module "Purge".)

No description.

Template parameters

ParameterDescriptionTypeStatus
Yearyear

no description

Unknownoptional
Monthmonth

no description

Unknownoptional
Dayday

no description

Unknownoptional
Hourhour

no description

Unknownoptional
Minuteminute

no description

Unknownoptional
Secondsecond

no description

Unknownoptional
Eventevent

no description

Unknownoptional
Durationduration

no description

Unknownoptional
Eventstarteventstart

no description

Unknownoptional
Eventendeventend

no description

Unknownoptional