Open main menu

Changes

{{Documentation subpage}}
{{lua|Module:time}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->

'''Note:''' Most Wikipedia pages display a cached version of the page to reduce server load, so the template will only display the current time ''as of when the page was last parsed''. You can refresh the displayed time by clicking the {{small|[refresh]}} link.

==Parameters==
{{tld|Localtime}} supports one positional and three named parameters; none are required:
:<code>|''<nowiki><time zone></nowiki>''</code> – the first positional (unnamed) parameter, specifies the time zone for which the template is to provide a time output. If omitted, the template displays UTC time. A time zone is identified by an abbreviation of the time zone's standard-time name. Do not use a summertime or daylight saving time abbreviation; they will be ignored and produce an error message.
:{{para|df}} – date format; an expanded version of the same parameter used in {{tld|time}}. This parameter takes one of four values; values other than these are ignored:
::{{para|df|dmy}} – specifies day month year date format; time in 24-hour format
::{{para|df|dmy12}} – same as {{para|df|dmy}} except time in 12-hour AM/PM format
::{{para|df|mdy}} – specifies month day, year format; time in 24-hour format; default when a date format is not specified in the time zone's properties
::{{para|df|mdy12}} – same as {{para|df|mdy}} except time in 12-hour AM/PM format
::{{para|df|iso}} – renders the date/time in a form roughly adhering to the [[ISO 8601]] format (seconds omitted)
::{{para|df|y}} – legacy {{tld|time}} parameter, same as {{para|df|dmy}}
:{{para|dst}} – when set to <code>no</code>, disables the daylight saving time calculation for the time zone; other values ignored; useful for locations within a time zone that do not observe daylight saving time; [[Arizona]], for example
:{{para|align}} - the alignment of the template (default right). Can support any [[HTML]] alignment.

== Usage ==
Typically, all that is needed is:
:<code><nowiki>{{</nowiki>Localtime|''<TZ>''}}</code> where <code>''<TZ>''</code> is one of the supported time zone abbreviations
::<code><nowiki>{{Localtime|MST}}</nowiki></code>{{Localtime|MST|align=left}}
To change the rendered format:
:<code><nowiki>{{Localtime|MST|df=dmy12}}</nowiki></code>{{Localtime|MST|df=dmy12|align=left}}
:<code><nowiki>{{Localtime|MST|df=mdy}}</nowiki></code>{{Localtime|MST|df=mdy|align=left}}
:<code><nowiki>{{Localtime|MST|df=iso}}</nowiki></code>{{Localtime|MST|df=iso|align=left}}

===UTC offset===
To display the time at a particular UTC offset, specify the UTC time offset as the time zone:
:<code><nowiki>{{time|UTC-07:00}}</nowiki></code>{{Localtime|UTC-07:00|align=left}}
'UTC', a sign character, two hour digits, a colon, and two minute digits are required. Accepted sign characters are: '+', '-' (hyphen), '±', and '−' (minus).

===Military/nautical time zones===
To display the time at a particular [[military time zones|military]] or [[nautical time zone]],<ref>{{cite web |url=http://astro.ukho.gov.uk/nao/miscellanea/WMTZ/ |title=World Time Zone Map |website=HM Nautical Almanac Office |date=February 2016}}</ref> use the time zone's alpha designation:
:<code><nowiki>{{time|M}}</nowiki></code>{{Localtime|M|align=left}}
Some military and nautical time zone designators are extended with an asterisk (*), a dagger (†), or double dagger (‡). When writing this template for designators that are extended with a dagger or double dagger, use '+' and '++' respectively:
:<code><nowiki>{{time|M++}}</nowiki></code>{{Localtime|M++|align=left}}
:<code><nowiki>{{time|M+}}</nowiki></code>{{Localtime|M+|align=left}}

===Daylight saving time===
Daylight saving time (DST) calculations are automatic for those time zones where it is observed. There are locales that do not observe DST within time zones where it is generally observed. To render the correct time for a non-observant locale, set {{para|dst|no}}:
:<code><nowiki>{{time|MST|dst=no}}</nowiki></code>{{Localtime|MST|dst=no|align=left}} – [[time in Arizona]]
:<code><nowiki>{{time|MST}}</nowiki></code>{{Localtime|MST|align=left}} – but, time on the [[Navajo Nation]] in Arizona

The opposite case is not supported. For places like [[Thule Air Base]] in Greenland, which observes US DST rules while WGT observes EU DST rules, a time zone properties table will be needed in Module:Time. See §[[#Adding a new time zone|Adding a new time zone]].

==Error messages==
{{tld|Localtime}} can produce several error messages. These are:
:<span style="font-size:100%" class="error"><nowiki>{{Localtime}</nowiki>} – unknown timezone</span> – the time zone positional parameter is not one of the supported time zone abbreviations. To resolve this error check the parameter's spelling or add the time zone's properties to the module. See §[[#Adding a new time zone|Adding a new time zone]].
:<span style="font-size:100%" class="error"><nowiki>{{Localtime}}</nowiki> – error calculating dst timestamps</span> – indicates an internal error because one or more of the following time zone properties is malformed: UTC offset, DST begin or end definition. To resolve this error make sure that the time zone's properties are correct.
:<span style="font-size:100%" class="error"><nowiki>{{Localtime}}</nowiki> – incomplete definition for ...</span> – indicates an internal error because one or more of the following time zone properties is missing: DST begin or end definition, DST event time, time zone article. To resolve this error supply the missing properties.

==Adding a new time zone==
{{tld|Localtime}} uses [[Module:Time]]. In that module, is a table of tables, the data structure that specifies the properties of the individual time zones. A blank time zone properties table has this form:
<pre>[''] = {
abbr = '',
dst_abbr = '',
utc_offset = '',
df = '',
dst_begins = '',
dst_ends = '',
dst_time = '',
dst_e_time = '',
article = ''
},</pre>

To add a new time zone to Module:Time, add the appropriate information inside the single quotes. If a property does not apply, leave the quotes empty. The rules for each property are:
:<code><nowiki>['']</nowiki></code> – (required) the abbreviation of a time zone's standard time; must be lower case; this is the value that will be used in the template's time zone pararameter
:<code><nowiki>abbr = ''</nowiki></code> – (required) the abbreviation of a time zone's standard time as it will be rendered by the template
:<code><nowiki>dst_abbr = ''</nowiki></code> – the abbreviation of a time zone's daylight saving or summer time as it will be rendered by the template
:<code><nowiki>utc_offset = ''</nowiki></code> – (required) the offset in hours and minutes from [[UTC±00:00]]; has the form: <code><nowiki>utc_offset = '<sign>hh:mm'</nowiki></code> where <code><sign></code> may be <code>+</code> (optional) or <code>-</code> (required for time zones west of the 0 meridian)
:<code><nowiki>df = ''</nowiki></code> – one of three keywords <code>dmy</code>, <code>mdy</code>, or <code>iso</code> used to specify date format typically used in the time zone; can be overridden with {{para|df}} template parameter
:<code><nowiki>dst_begins = ''</nowiki></code> – a four word sentence in the form <code><ordinal></code> <code><day name></code> <code><in|of></code> <code><month name></code> where:
::<code><ordinal></code> – any of the words 'first', '1st', 'second', '2nd', ... 'fifth', '5th', or 'last'
::<code><day name></code> – any of the day names 'Sunday', 'Monday', 'Tuesday', etc.; capitalization is not important but otherwise must be spelled correctly; abbreviations not supported
::<code><in|of></code> – either of the words 'in' or 'of'
::<code><month name></code> – any of the month names 'January', 'February', 'March', etc.; capitalization is not important but otherwise must be spelled correctly; abbreviations not supported
:<code><nowiki>dst_ends = ''</nowiki></code> – (required if <code>dst_begins</code> is specified) same as <code>dst_begins</code>
:<code><nowiki>dst_time = ''</nowiki></code> – (required if <code>dst_begins</code> is specified) the time that daylight saving time begins; usually local time; when DST begins at a specified time UTC ([[European Summer Time]] for example) use: <code>dst_time = 'hh:mm UTC'</code>; four digits and the colon are required
:<code><nowiki>dst_e_time = ''</nowiki></code> – the time that daylight saving time ends if different from the time it begins; usually local daylight saving time ; when DST ends at a specified time UTC use: <code>dst_e_time = 'hh:mm UTC'</code>; four digits and the colon are required
:<code><nowiki>article = ''</nowiki></code> – (required) the title of a Wikipedia article that is appropriate to the timezone; do not include wikimarkup

The table-of-tables is organized east (plus UTC offsets) then west (minus UTC offset), by offset hours, and then alphabetically by time zone positional parameter name.

==See also==
{{Date and time templates}}

==References==
{{reflist}}

<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Time, date and calendar templates]]
}}</includeonly>


<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->

}}</includeonly>
Anonymous user