Template:Event timer/doc: Difference between revisions

From 118Wiki
Jump to navigation Jump to search
(Basics. WIP)
 
m (actually remove wip this time)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:UnderConstruction|Jovenan}}
This template shows a message between selected dates. The message will be shown annually between those dates. More flexible usage is possible as described in the documentation.
This template shows a message between selected dates. The message will be shown annually between those dates. More flexible usage is possible as described in the documentation.


Line 7: Line 5:
Full usage:
Full usage:
<pre>{{Event timer | Start = | End = | Message = | End message = | Future message = | Today = }}</pre>
<pre>{{Event timer | Start = | End = | Message = | End message = | Future message = | Today = }}</pre>
<div style="width:80%; background-color: lemonchiffon; border: 2px solid darkgoldenrod; text-align: center; margin:auto;">NOTE! <br> The template doesn't work in real time, but receives the current day from the server when a new cache is loaded. As such, the template is prone to "getting stuck". If that happens, you can purge the cache. Consider including the [[Template:Purge]] in your message for user convenience.</div>


=== Parameters ===
=== Parameters ===
Line 19: Line 19:


'''Today''' is if you, for some reason, want to compare the start date and end date for some specific date. This parameter is recommended only for advanced use.
'''Today''' is if you, for some reason, want to compare the start date and end date for some specific date. This parameter is recommended only for advanced use.
=== Dates ===
The template uses parser function <nowiki>{{#time: }}</nowiki>, which can interpret several different date formats. At least the following formats work in the template.
{| class="wikitable"
! Format !! Example
|-
| colspan="2" bgcolor=#343434 style="text-align:center; color:white;" | '''Recommended'''
|-
| Day number + Month name || 9 October
|-
| Month name + Day number || October 9
|-
| Day number + Month Abbr. || 9 Oct
|-
| Month Abbr. + Day number || Oct 9
|-
| Month/Day (US style) || 10/9
|-
| colspan="2" bgcolor=#343434 style="text-align:center; color:white;" | '''Other'''
|-
| Month<ref group="note">Do not include the year when using only the name of the month.</ref> || Oct <br> October
|-
| ISO<ref group="note">Including the year is mandatory, even if it's ignored. The year can be any year.</ref> || 2023-10-09
|-
| Weekdays<ref group="note">Will find the ''next'' weekday given! As such, the value "Wednesday" will refer to Wednesday this week on Monday, Tuesday and Wednesday, but to the next week's Wednesday on all the other days.</ref> || Tue <br> Tuesday
|}
<small><references group="note"/></small>
=== Further notes ===
The template operates using UTC time. As such, the day will change at midnight UTC, which might be different from the midnight in your location.
The template doesn't understand time periods that start and end different years, e.g. 25 Dec to 17 Jan. If the new year's day is between the start date and the end date, you need to call the template twice.
== Examples ==
=== Basic use ===
<pre>{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | End message = '''Autumn has passed.''' | Future message = '''There's still time until autumn.'''}}</pre>
Let's assume today is 10th October, which is between 23rd September and 22 December. Now, the template will render like this:
{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | End message = '''Autumn has passed.''' | Future message = '''There's still time until autumn.''' | Today = 10 Oct}}
If it was 4th July, before those dates, instead, we'd have the following render instead:
{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | End message = '''Autumn has passed.''' | Future message = '''There's still time until autumn.''' | Today = 4 Jul}}
And, if it was 25th December, after those dates, this is what we would get:
{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | End message = '''Autumn has passed.''' | Future message = '''There's still time until autumn.''' | Today = 10 Oct}}
=== Omitting end and future messages ===
We don't have to show anything before or after the selected dates.
<pre>{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.'''}}</pre>
So, on 10th October we will see this:
{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | Today = 10 Oct}}
But on 4th July and 25th December, we will see nothing.
{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | Today = 25 Dec}}
=== Single-day ===
<pre>{{Event timer | Start = 26 Oct | End = 26 Oct | Message = '''Happy birthday, [[Jovenan]]!''' | End message = '''Jovenan's birthday has passed.''' | Future message = '''It's not yet Jovenan's birthday'''}}</pre>
On 26th October, we will have the following:
{{Event timer | Start = 26 Oct | End = 26 Oct | Message = '''Happy birthday, [[Jovenan]]!''' | End message = '''Jovenan's birthday has passed.''' | Future message = '''It's not yet Jovenan's birthday''' | Today =  26 Oct}}
Otherwise, we will have either of these:
{{Event timer | Start = 26 Oct | End = 26 Oct | Message = '''Happy birthday, [[Jovenan]]!''' | End message = '''Jovenan's birthday has passed.''' | Future message = '''It's not yet Jovenan's birthday''' | Today =  1 Jan}}
{{Event timer | Start = 26 Oct | End = 26 Oct | Message = '''Happy birthday, [[Jovenan]]!''' | End message = '''Jovenan's birthday has passed.''' | Future message = '''It's not yet Jovenan's birthday''' | Today =  31 Dec}}
=== Styling ===
<pre>{{Event timer | Start = 26 Oct | End = 26 Oct | Message = <div style="width: 80%; margin:auto; text-align: center; border: 3px double blue; background-color: lightsteelblue; font-size: 20px">Happy birthday, Jovenan!</div>}}</pre>
On 26th October, we will see this:
{{Event timer | Start = 26 Oct | End = 26 Oct | Message = <div style="width: 80%; margin:auto; text-align: center; border: 3px double blue; background-color: lightsteelblue; font-size: 20px">Happy birthday, Jovenan!</div>  | End message = '''Jovenan's birthday has passed.''' | Future message = '''It's not yet Jovenan's birthday'''| Today = 26 Oct}}
<includeonly>[[Category:Templates]]</includeonly>
<noinclude>[[Category:Documentation subpages]]</noinclude>

Latest revision as of 13:36, 10 October 2023

This template shows a message between selected dates. The message will be shown annually between those dates. More flexible usage is possible as described in the documentation.

Usage

Full usage:

{{Event timer | Start = | End = | Message = | End message = | Future message = | Today = }}
NOTE!
The template doesn't work in real time, but receives the current day from the server when a new cache is loaded. As such, the template is prone to "getting stuck". If that happens, you can purge the cache. Consider including the Template:Purge in your message for user convenience.

Parameters

All parameters are optional.

Start is for the start date and End is for the end date. If start date is omitted, the message will be shown until the end date from the beginning of the year. If end date is omitted, the message will be shown until the end of the year. If both are omitted, the message will be shown around the year.

Message is the message you want to show between start and end.

End message is shown after the end date has passed, and Future message is shown before the start date. If either is omitted, no message is shown during those times.

Today is if you, for some reason, want to compare the start date and end date for some specific date. This parameter is recommended only for advanced use.

Dates

The template uses parser function {{#time: }}, which can interpret several different date formats. At least the following formats work in the template.

Format Example
Recommended
Day number + Month name 9 October
Month name + Day number October 9
Day number + Month Abbr. 9 Oct
Month Abbr. + Day number Oct 9
Month/Day (US style) 10/9
Other
Month[note 1] Oct
October
ISO[note 2] 2023-10-09
Weekdays[note 3] Tue
Tuesday
  1. Do not include the year when using only the name of the month.
  2. Including the year is mandatory, even if it's ignored. The year can be any year.
  3. Will find the next weekday given! As such, the value "Wednesday" will refer to Wednesday this week on Monday, Tuesday and Wednesday, but to the next week's Wednesday on all the other days.

Further notes

The template operates using UTC time. As such, the day will change at midnight UTC, which might be different from the midnight in your location.

The template doesn't understand time periods that start and end different years, e.g. 25 Dec to 17 Jan. If the new year's day is between the start date and the end date, you need to call the template twice.

Examples

Basic use

{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.''' | End message = '''Autumn has passed.''' | Future message = '''There's still time until autumn.'''}}

Let's assume today is 10th October, which is between 23rd September and 22 December. Now, the template will render like this:

It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.

If it was 4th July, before those dates, instead, we'd have the following render instead:

There's still time until autumn.

And, if it was 25th December, after those dates, this is what we would get:

It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.

Omitting end and future messages

We don't have to show anything before or after the selected dates.

{{Event timer | Start = 23 Sept | End = 22 Dec | Message = '''It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.'''}}

So, on 10th October we will see this:

It's autumn in the Northern Hemisphere on Earth accoring to the astronomical definition.

But on 4th July and 25th December, we will see nothing.


Single-day

{{Event timer | Start = 26 Oct | End = 26 Oct | Message = '''Happy birthday, [[Jovenan]]!''' | End message = '''Jovenan's birthday has passed.''' | Future message = '''It's not yet Jovenan's birthday'''}}

On 26th October, we will have the following:

Happy birthday, Jovenan!

Otherwise, we will have either of these:

It's not yet Jovenan's birthday

Jovenan's birthday has passed.

Styling

{{Event timer | Start = 26 Oct | End = 26 Oct | Message = <div style="width: 80%; margin:auto; text-align: center; border: 3px double blue; background-color: lightsteelblue; font-size: 20px">Happy birthday, Jovenan!</div>}}

On 26th October, we will see this:

Happy birthday, Jovenan!