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

From blackwiki
Jump to navigation Jump to search
imported>Thayts
(-IST due to abbr. collisions)
imported>Thayts
(moved simplified logic to an 'offset' template; using that template now)
 
Line 1: Line 1:
{{#switch:{{uc:{{{1|}}}}}
+
<!--This template makes use of other templates and it should never require any changes.
<!--Hawaii Standard Time-->
+
    The #iferror check is included to prevent the hour offset (if given instead of
|HST=
+
    a time zone abbreviation) from being used as the minute offset.
{{#time:H|-10 hours}} <!--UTC-10 standard time-->
+
 
<!--Hawaii-Aleutian Time-->
+
-->{{#time:H|{{Current hour offset in time zone|{{{1|}}}|dst={{{dst|{{{autoDST|}}}}}}}} hours {{#iferror:{{#time:H|-{{{1|0}}} hours}}|{{Current minute offset in time zone|{{{1|}}}}} minutes|}}}}<!--
|HAT|HAST|HADT
+
 
<!--Alaska Time-->
+
--><noinclude>
|AKT|AKST|AKDT
 
<!--Pacific Time (Northern America)-->
 
|PT|PST|PDT
 
<!--Mountain Time (Northern America)-->
 
|MT|MST|MDT
 
<!--Central Time (Northern America)-->
 
|CT|CST|CDT
 
<!--Eastern Time (Northern America)-->
 
|ET|EST|EDT
 
<!--Atlantic Time-->
 
|AT|AST|ADT
 
<!--Newfoundland Time-->
 
|NT|NST|NDT=
 
{{#ifexpr:({{#ifeq:{{{autoDST|}}}|no|0|1}} <!--automatically calculate DST time or not-->
 
        and {{Daylight saving in time zone|{{uc:{{{1}}}}}}} <!--DST active or not-->
 
          )
 
        or ({{#ifeq:{{{autoDST|}}}|no|1|0}} and {{#switch:{{uc:{{{1}}}}}|HADT|AKDT|PDT|MDT|CDT|EDT|ADT|NDT=1|0}}) <!--if no automatic DST take difference between xST/xDT into account-->
 
  |{{#time:H|{{#switch:{{uc:{{{1}}}}}|HAT|HAST|HADT=-9|AKT|AKST|AKDT=-8|PT|PST|PDT=-7|MT|MST|MDT=-6|CT|CST|CDT=-5|ET|EST|EDT=-4|AT|AST|ADT=-3|NT|NST|NDT=-2}} hours {{#switch:{{uc:{{{1}}}}}|NT|NST|NDT=-30|0}} minutes}} <!--UTC-x+1 during DST-->
 
  |{{#time:H|{{#switch:{{uc:{{{1}}}}}|HAT|HAST|HADT=-10|AKT|AKST|AKDT=-9|PT|PST|PDT=-8|MT|MST|MDT=-7|CT|CST|CDT=-6|ET|EST|EDT=-5|AT|AST|ADT=-4|NT|NST|NDT=-3}} hours {{#switch:{{uc:{{{1}}}}}|NT|NST|NDT=-30|0}} minutes}} <!--UTC-x standard time-->
 
}}
 
<!--Greenwich Mean Time / British Summer Time (same as WET / WEST)-->
 
|GMT|BST
 
<!--Western European Time-->
 
|WET|WEST
 
<!--Central European Time-->
 
|CET|CEST
 
<!--Eastern European Time-->
 
|EET|EEST=
 
{{#ifexpr:({{#ifeq:{{{autoDST|}}}|no|0|1}} <!--automatically calculate DST time or not-->
 
        and {{Daylight saving in time zone|{{uc:{{{1}}}}}}} <!--DST active or not-->
 
          )
 
        or ({{#ifeq:{{{autoDST|}}}|no|1|0}} and {{#switch:{{uc:{{{1}}}}}|BST|WEST|CEST|EEST=1|0}}) <!--if no automatic DST take difference between xET/xEST into account-->
 
  |{{#time:H|{{#switch:{{uc:{{{1}}}}}|GMT|BST|WET|WEST=1|CET|CEST=2|EET|EEST=3}} hours}} <!--UTC+x+1 during DST-->
 
  |{{#time:H|{{#switch:{{uc:{{{1}}}}}|GMT|BST|WET|WEST=0|CET|CEST=1|EET|EEST=2}} hours}} <!--UTC+x standard time-->
 
}}
 
<!--Australian Western Time-->
 
|AWT|AWST=
 
{{#time:H|8 hours}} <!--UTC+8 standard time-->
 
<!--Australian Central Time-->
 
|ACT|ACST|ACDT
 
<!--Australian Eastern Time-->
 
|AET|AEST|AEDT=
 
{{#ifexpr:({{#ifeq:{{{autoDST|}}}|no|0|1}} <!--automatically calculate DST time or not-->
 
        and {{Daylight saving in time zone|{{uc:{{{1}}}}}}} <!--DST active or not-->
 
          )
 
        or ({{#ifeq:{{{autoDST|}}}|no|1|0}} and {{#switch:{{uc:{{{1}}}}}|ACDT|AEDT=1|0}}) <!--if no automatic DST take difference between xST/xDT into account-->
 
  |{{#time:H|{{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=10|AET|AEST|AEDT=11}} hours {{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=30|0}} minutes}} <!--UTC+x+1 during DST-->
 
  |{{#time:H|{{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=9|AET|AEST|AEDT=10}} hours {{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=30|0}} minutes}} <!--UTC+x standard time-->
 
}}
 
<!--Korea Standard Time-->
 
|KST
 
<!--Japan Standard Time-->
 
|JST=
 
{{#time:H|9 hours}} <!--UTC+9 standard time-->
 
<!--New Zealand Time-->
 
|NZT|NZST|NZDT=
 
{{#ifexpr:({{#ifeq:{{{autoDST|}}}|no|0|1}} <!--automatically calculate DST time or not-->
 
        and {{Daylight saving in time zone|{{uc:{{{1}}}}}}} <!--DST active or not-->
 
          )
 
        or ({{#ifeq:{{{autoDST|}}}|no|1|0}} and {{#switch:{{uc:{{{1}}}}}|NZDT=1|0}}) <!--if no automatic DST take difference between xST/xDT into account-->
 
  |{{#time:H|13 hours}} <!--UTC+13 during DST-->
 
  |{{#time:H|12 hours}} <!--UTC+12 standard time-->
 
}}
 
<!--default (UTC+offset)-->
 
|{{#iferror:{{#time:H|{{{1|0}}} hours}}|{{#time:H}}|{{#time:H|{{{1|0}}} hours}}}}
 
}}<noinclude>
 
 
{{documentation}}
 
{{documentation}}
 
[[Category:Date-computing templates based on current time]]</noinclude>
 
[[Category:Date-computing templates based on current time]]</noinclude>

Latest revision as of 16:00, 29 September 2012

14

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

This template gives the current hour in the given time zone in 24-hour format.

It makes use of {{Current hour offset in time zone}} which, unless the dst parameter is used, automatically adjusts the hour according to daylight saving time (DST), if applicable. It also makes use of {{Current minute offset in time zone}}.

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

Usage

{{Current hour 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 the current hour of UTC±0 time;
    In this case, instead of giving a time zone, an offset (e.g. -3, 1, 5, etc.) can also be given to get the current hour of UTC+offset time (which will not be adjusted according to DST);
  • 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 time zones that appear in both tables below are supported:

Hour offset
Standard time abbreviation Abbreviations Daylight saving time abbreviation Name Standard time offset Script error: No such module "Purge". Daylight saving time offset 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.

Minute offset
Standard time abbreviation Abbreviations Daylight saving time abbreviation Name Standard time offset Script error: No such module "Purge". Daylight saving time offset Notes
HST Hawaii Standard Time UTC10:00 The minute of standard time does not differ from the minute of daylight saving time (DST; if applicable).
HAT or HAST HADT Hawaii-Aleutian Standard/Daylight Time UTC10:00 UTC09:00
AKT or AKST AKDT Alaska Standard/Daylight Time UTC09:00 UTC08:00
PT or PST PDT Pacific Standard/Daylight Time UTC08:00 UTC07:00
MT or MST MDT Mountain Standard/Daylight Time UTC07:00 UTC06:00
SKT or SKST Saskatchewan Standard Time UTC06:00
CT or CST CDT Central Standard/Daylight Time UTC06:00 UTC05:00
ET or EST EDT Eastern Standard/Daylight Time UTC05:00 UTC04:00
AT or AST ADT Atlantic Standard/Daylight Time UTC04:00 UTC03:00
NT or NST NDT Newfoundland Standard/Daylight Time UTC03:30 UTC02:30
GMT BST Greenwich Mean Time /
British Summer Time
UTC+00:00 UTC+01:00
WET WEST Western European (Summer) Time UTC+00:00 UTC+01:00
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
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
JST Japan Standard Time UTC+09:00
NZT or NZST NZDT New Zealand Standard/Daylight Time UTC+12:00 UTC+13:00

Time zone map

Examples

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


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

produces

  • 15


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

produces

  • 15


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

produces

  • 15


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

produces

  • 16


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

produces

  • 07


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

produces

  • 10


*{{Current hour in time zone}}

produces

  • 14


*{{Current hour in time zone|ACT}}:{{Current minute in time zone|ACT}}

produces

  • 00:53

Related templates

Current time

Current offset

Daylight savings