Difference between revisions of "Template:Current hour offset in time zone"

From blackwiki
Jump to navigation Jump to search
imported>Jonesey95
(Undid revision 855757225 by Jonesey95 (talk). self-revert)
imported>Enterprisey
(restore version from 2014 to see if it fixes the templates that depend on this one)
 
Line 1: Line 1:
{{offset|{{{1|UTC}}}|houronly=yes}}<noinclude>{{doc}}</noinclude>
+
<!--
 +
  HOW TO ADD A TIME ZONE
 +
 
 +
* Add a pipe (|) chain with all the abbreviations of the time zone,
 +
  including both the standard time abbreviation(s) and daylight saving
 +
  time abbreviation, ending the line with an equal sign (=) followed
 +
  by the hour offset from UTC during /standard/ time.
 +
 
 +
  Example: |abbr1|abbr2|abbr3=-9
 +
 
 +
* Add the daylight saving time abbreviation (if any) to the pipe chain
 +
  in the expression near the bottom, but make sure that the last
 +
  abbreviation in the chain is still directly followed by '=1'.
 +
 
 +
* Update the documentation.
 +
 
 +
* Add the time zone to Template:Current_minute_offset_in_time_zone.
 +
 
 +
* Consider adding the time zone to Template:Daylight_saving_in_time_zone
 +
  to enable automatic DST adjustment. If DST is observed in the time zone
 +
  but the time zone has not been implemented in that template, then
 +
  please make a note in the documentation that automatic DST adjustment
 +
  is currently not supported for that time zone.
 +
 
 +
-->{{#expr:{{#switch:{{uc:{{{1|}}}}}
 +
 
 +
<!--Hawaii Standard Time-->
 +
|HST=-10 <!--UTC-10 all year-->
 +
 
 +
<!--Hawaii-Aleutian Time-->
 +
|HAT|HAST|HADT=-10
 +
 
 +
<!--Alaska Time-->
 +
|AKT|AKST|AKDT=-9
 +
 
 +
<!--Pacific Time (Northern America)-->
 +
|PT|PST|PDT=-8
 +
 
 +
<!--Mountain Time (Northern America)-->
 +
|MT|MST|MDT=-7
 +
 
 +
<!--Saskatchewan Time (except Lloydminster, SK) (Canada)-->
 +
|SKT|SKST=-6 <!--UTC-6 all year-->
 +
 
 +
<!--Central Time (Northern America)-->
 +
|CT|CST|CDT=-6
 +
 
 +
<!--Eastern Time (Northern America)-->
 +
|ET|EST|EDT=-5
 +
 
 +
<!--Atlantic Time-->
 +
|AT|AST|ADT=-4
 +
 
 +
<!--Newfoundland Time-->
 +
|NT|NST|NDT=-3
 +
 
 +
<!--Greenwich Mean Time / British Summer Time (same as WET / WEST)-->
 +
|GMT|BST=0
 +
 
 +
<!--Western European Time-->
 +
|WET|WEST=0
 +
 
 +
<!--Central European Time-->
 +
|CET|CEST=1
 +
 
 +
<!--Eastern European Time-->
 +
|EET|EEST=2
 +
 
 +
<!--Australian Western Time-->
 +
|AWT|AWST=8 <!--UTC+8 all year-->
 +
 
 +
<!--Australian Central Time-->
 +
|ACT|ACST|ACDT=9
 +
 
 +
<!--Australian Eastern Time-->
 +
|AET|AEST|AEDT=10
 +
 
 +
<!--Korea Standard Time-->
 +
|KST=9 <!--UTC+9 all year-->
 +
 
 +
<!--Japan Standard Time-->
 +
|JST=9 <!--UTC+9 all year-->
 +
 
 +
<!--New Zealand Time-->
 +
|NZT|NZST|NZDT=12
 +
 
 +
<!--default (input offset, or otherwise 0)-->
 +
|{{#iferror:{{#time:H|-{{{1|0}}} hours}}|0|{{{1|0}}}}}
 +
}}
 +
 
 +
{{#ifexpr:({{#ifeq:{{{dst|}}}|no|0|1}} <!--if automatic DST-->
 +
      and {{Daylight saving in time zone|{{uc:{{{1|}}}}}}} <!--then if DST is active-->
 +
          )
 +
      or ({{#ifeq:{{{dst|}}}|no|1|0}} <!--or, if no automatic DST-->
 +
      and {{#switch:{{uc:{{{1|}}}}}|HADT|AKDT|PDT|MDT|CDT|EDT|ADT|NDT|BST|WEST|CEST|EEST|ACDT|AEDT|NZDT=1|0}} <!--then if DST abbreviation is used-->
 +
          )
 +
|+1 <!--+1 during DST-->
 +
}}}}<noinclude>
 +
{{documentation}}
 +
[[Category:Date-computing templates based on current time]]</noinclude>

Latest revision as of 20:41, 20 August 2018

0

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

This template gives the current hour offset from UTC time for the given time zone.

If the dst parameter is not used, it uses {{Daylight saving in time zone}} to automatically adjust the offset according to daylight saving time (DST), if applicable.

This template can be used in conjunction with {{Current minute offset in time zone}} to calculate the current time in a particular time zone. See below for the currently supported time zones.

Usage

{{Current hour offset in time zone|time zone[|dst=no]}}
([...] means optional, do not include the square brackets when using this template)

where

  • time zone is the desired time zone abbreviation (see below and also the list of time zone abbreviations);
    If no time zone is given or if the given time zone is not supported, then the output will default to 0;
    In this case, instead of giving a time zone, an offset (e.g. -3, 1, 5, etc.) can also be given;
    This exact offset will then be used as the output (this functionality is merely included for template compatibility);
  • dst is an optional parameter to disable automatic daylight saving time adjustment by setting the value to "no";
    If a DST variant of a particular time zone exists, then the time is automatically adjusted according to DST by default.

Supported time zones

Currently the following time zones are supported:

SDT - Abbreviations - DST Name SDT - Script error: No such module "Purge". - DST Notes
HST Hawaii Standard Time UTC−10:00 When dst is NOT set to "no", the *T, *ST and *DT variants of a particular time zone will produce the same output and can be used interchangeably.

Otherwise (when using dst=no), *T and *ST will produce the offset without DST adjustment, and *DT will produce the offset with DST adjustment.

DST is not observed in Hawaii and in Saskatchewan, Canada (except Lloydminster, SK, where MST/MDT is observed).

HAT or HAST HADT Hawaii-Aleutian Standard/Daylight Time UTC−10:00 UTC−09:00
AKT or AKST AKDT Alaska Standard/Daylight Time UTC−09:00 UTC−08:00
PT or PST PDT Pacific Standard/Daylight Time UTC−08:00 UTC−07:00
MT or MST MDT Mountain Standard/Daylight Time UTC−07:00 UTC−06:00
SKT or SKST Saskatchewan Standard Time UTC−06:00
CT or CST CDT Central Standard/Daylight Time UTC−06:00 UTC−05:00
ET or EST EDT Eastern Standard/Daylight Time UTC−05:00 UTC−04:00
AT or AST ADT Atlantic Standard/Daylight Time UTC−04:00 UTC−03:00
NT or NST NDT Newfoundland Standard/Daylight Time UTC−03:30 UTC−02:30
GMT BST Greenwich Mean Time /
British Summer Time
UTC+00:00 UTC+01:00 When dst is NOT set to "no", both the GMT and BST variants of this time zone will produce the same output and can be used interchangeably.

Otherwise (when using dst=no), GMT will produce the offset without DST adjustment, and BST will produce the offset with DST adjustment.

WET WEST Western European (Summer) Time UTC+00:00 UTC+01:00 When dst is NOT set to "no", both the *ET and *EST variants of a particular time zone will produce the same output and can be used interchangeably.

Otherwise (when using dst=no), *ET will produce the offset without DST adjustment, and *EST will produce the offset with DST adjustment.

CET CEST Central European (Summer) Time UTC+01:00 UTC+02:00
EET EEST Eastern European (Summer) Time UTC+02:00 UTC+03:00
AWT or AWST Australian Western Standard Time UTC+08:00 When dst is NOT set to "no", the *T, *ST and *DT variants of a particular time zone will produce the same output and can be used interchangeably.

Otherwise (when using dst=no), *T and *ST will produce the offset without DST adjustment, and *DT will produce the offset with DST adjustment.

DST is not observed in the AWT time zone.

ACT or ACST ACDT Australian Central Standard/Daylight Time UTC+09:30 UTC+10:30
AET or AEST AEDT Australian Eastern Standard/Daylight Time UTC+10:00 UTC+11:00
KST Korea Standard Time UTC+09:00 DST is not observed in these time zones. It is not necessary to set dst.
JST Japan Standard Time UTC+09:00
NZT or NZST NZDT New Zealand Standard/Daylight Time UTC+12:00 UTC+13:00 When dst is NOT set to "no", the NZT, NZST and NZDT variants of this time zone will produce the same output and can be used interchangeably.

Otherwise (when using dst=no), NZT and NZST will produce the offset without DST adjustment, and NZDT will produce the offset with DST adjustment.

Time zone map

UTC hue4map X world Robinson - explicit offsets.png

Examples

(You may want to Script error: No such module "Purge". this page to update the output.)


*{{Current hour offset in time zone|CET}}

produces

  • 1


*{{Current hour offset in time zone|CET|dst=no}}

produces

  • 1


*{{Current hour offset in time zone|CEST}}

produces

  • 1


*{{Current hour offset in time zone|CEST|dst=no}}

produces

  • 2


*{{Current hour offset in time zone|PT}}

produces

  • -8


*{{Current hour offset in time zone|-4}}

produces

  • -4


*{{Current hour offset in time zone}}

produces

  • 0

Related templates

Current time

Current offset

Daylight savings