Difference between revisions of "Template:Daylight saving active"

From blackwiki
Jump to navigation Jump to search
imported>Thayts
m
imported>Thayts
(Replaced complicated formulas with simpler logic, and added a second parameter to get DST at a given time)
Line 3: Line 3:
  
 
  * Add a pipe (|) chain with all the abbreviations of the time zones
 
  * Add a pipe (|) chain with all the abbreviations of the time zones
   for which the same formula is used to calculate the dates at which
+
   for which the same logic is used to calculate the dates at which
 
   DST begins and ends, including both the standard time abbreviation(s)
 
   DST begins and ends, including both the standard time abbreviation(s)
 
   and daylight saving time abbreviation for each time zone, ending the
 
   and daylight saving time abbreviation for each time zone, ending the
   chain with an equal sign (=) followed by the formula.
+
   chain with an equal sign (=) followed by the logic.
  
 
  * Update the documentation.
 
  * Update the documentation.
Line 12: Line 12:
 
  * Also update the technical documentation, found at /techdoc, to
 
  * Also update the technical documentation, found at /techdoc, to
 
   describe at what date and time DST begins and ends as implemented
 
   describe at what date and time DST begins and ends as implemented
   by the formula.
+
   by the logic.
  
 
-->{{#switch:{{uc:{{{1|}}}}}
 
-->{{#switch:{{uc:{{{1|}}}}}
Line 24: Line 24:
 
<!--Hawaii-Aleutian Time-->
 
<!--Hawaii-Aleutian Time-->
 
|HAT|HAST|HADT
 
|HAT|HAST|HADT
 
 
<!--Alaska Time-->
 
<!--Alaska Time-->
 
|AKT|AKST|AKDT
 
|AKT|AKST|AKDT
 
 
<!--Pacific Time (Northern America)-->
 
<!--Pacific Time (Northern America)-->
 
|PT|PST|PDT
 
|PT|PST|PDT
 
 
<!--Mountain Time (Northern America)-->
 
<!--Mountain Time (Northern America)-->
 
|MT|MST|MDT
 
|MT|MST|MDT
 
 
<!--Central Time (Northern America)-->
 
<!--Central Time (Northern America)-->
 
|CT|CST|CDT
 
|CT|CST|CDT
 
 
<!--Eastern Time (Northern America)-->
 
<!--Eastern Time (Northern America)-->
 
|ET|EST|EDT
 
|ET|EST|EDT
 
 
<!--Atlantic Time-->
 
<!--Atlantic Time-->
 
|AT|AST|ADT
 
|AT|AST|ADT
 
 
<!--Newfoundland Time-->
 
<!--Newfoundland Time-->
 
|NT|NST|NDT=
 
|NT|NST|NDT=
  {{#ifexpr:
+
  {{#expr:
      <!--April through October-->
+
  {{#time:Ymd|{{#time:Y|{{{2|}}}}}0314-{{#time:w|{{#time:Y|{{{2|}}}}}0314}}days}}{{#switch:{{uc:{{{1}}}}}|HAT|HAST|HADT=1200|AKT|AKST|AKDT=1100|PT|PST|PDT=1000|MT|MST|MDT=0900|CT|CST|CDT=0800|ET|EST|EDT=0700|AT|AST|ADT=0600|NT|NST|NDT=0530}} <=
          ({{#time:n}} > 3  and {{#time:n}} < 11)
+
  {{#time:YmdHi|{{{2|}}}}} and
      <!--date in March after start DST-->
+
  {{#time:YmdHi|{{{2|}}}}} <
        or ({{#time:n}} = 3  and {{#time:j}} > {{#expr:(14 - (5*{{#time:Y}}/4 + 1) mod 7)}})
+
  {{#time:Ymd|{{#time:Y|{{{2|}}}}}1107-{{#time:w|{{#time:Y|{{{2|}}}}}1107}}days}}{{#switch:{{uc:{{{1}}}}}|HAT|HAST|HADT=1100|AKT|AKST|AKDT=1000|PT|PST|PDT=0900|MT|MST|MDT=0800|CT|CST|CDT=0700|ET|EST|EDT=0600|AT|AST|ADT=0500|NT|NST|NDT=0430}}
      <!--date in November before end DST-->
 
        or ({{#time:n}} = 11 and {{#time:j}} < {{#expr:(7  - (5*{{#time:Y}}/4 + 1) mod 7)}})
 
      <!--day of start DST after 2 AM local standard time (second Sunday in March)-->
 
        or ({{#time:n}} = 3  and {{#time:j}} = {{#expr:(14 - (5*{{#time:Y}}/4 + 1) mod 7)}} and {{#time:G|{{#switch:{{uc:{{{1}}}}}|NT|NST|NDT=-30|0}} minutes}} >= {{#switch:{{uc:{{{1}}}}}|HAT|HAST|HADT=12|AKT|AKST|AKDT=11|PT|PST|PDT=10|MT|MST|MDT=9|CT|CST|CDT=8|ET|EST|EDT=7|AT|AST|ADT=6|NT|NST|NDT=5}})
 
      <!--day of end DST before 2 AM local daylight saving time (first Sunday in November)-->
 
        or ({{#time:n}} = 11 and {{#time:j}} = {{#expr:(7  - (5*{{#time:Y}}/4 + 1) mod 7)}} and {{#time:G|{{#switch:{{uc:{{{1}}}}}|NT|NST|NDT=-30|0}} minutes}} < {{#switch:{{uc:{{{1}}}}}|HAT|HAST|HADT=11|AKT|AKST|AKDT=10|PT|PST|PDT=9|MT|MST|MDT=8|CT|CST|CDT=7|ET|EST|EDT=6|AT|AST|ADT=5|NT|NST|NDT=4}})
 
  |1 <!--DST active-->
 
  |0 <!--DST not active-->
 
 
  }}
 
  }}
  
 
<!--Greenwich Mean Time / British Summer Time (same as WET / WEST)-->
 
<!--Greenwich Mean Time / British Summer Time (same as WET / WEST)-->
 
|GMT|BST
 
|GMT|BST
 
 
<!--Western European Time-->
 
<!--Western European Time-->
 
|WET|WEST
 
|WET|WEST
 
 
<!--Central European Time-->
 
<!--Central European Time-->
 
|CET|CEST
 
|CET|CEST
 
 
<!--Eastern European Time-->
 
<!--Eastern European Time-->
 
|EET|EEST=
 
|EET|EEST=
  {{#ifexpr:
+
  {{#expr:
      <!--April through September-->
+
  {{#time:Ymd|{{#time:Y|{{{2|}}}}}0331-{{#time:w|{{#time:Y|{{{2|}}}}}0331}}days}}01 <=
          ({{#time:n}} > 3  and {{#time:n}} < 10)
+
  {{#time:YmdH|{{{2|}}}}} and
      <!--date in March after start DST-->
+
  {{#time:YmdH|{{{2|}}}}} <
        or ({{#time:n}} = 3  and {{#time:j}} > {{#expr:(31 - (5*{{#time:Y}}/4 + 4) mod 7)}})
+
  {{#time:Ymd|{{#time:Y|{{{2|}}}}}1031-{{#time:w|{{#time:Y|{{{2|}}}}}1031}}days}}01
      <!--date in October before end DST-->
 
        or ({{#time:n}} = 10 and {{#time:j}} < {{#expr:(31 - (5*{{#time:Y}}/4 + 1) mod 7)}})
 
      <!--day of start DST after UTC+1 (last Sunday in March)-->
 
        or ({{#time:n}} = 3  and {{#time:j}} = {{#expr:(31 - (5*{{#time:Y}}/4 + 4) mod 7)}} and {{#time:G}} >= 1)
 
      <!--day of end DST before UTC+1 (last Sunday in October)-->
 
        or ({{#time:n}} = 10 and {{#time:j}} = {{#expr:(31 - (5*{{#time:Y}}/4 + 1) mod 7)}} and {{#time:G}} < 1)
 
  |1 <!--DST active-->
 
  |0 <!--DST not active-->
 
 
  }}
 
  }}
  
Line 91: Line 65:
 
<!--Australian Central Time-->
 
<!--Australian Central Time-->
 
|ACT|ACST|ACDT
 
|ACT|ACST|ACDT
 
 
<!--Australian Eastern Time-->
 
<!--Australian Eastern Time-->
 
|AET|AEST|AEDT=
 
|AET|AEST|AEDT=
  {{#ifexpr:
+
  {{#expr:
      <!--November through March-->
+
  {{#time:YmdHi|{{{2|}}}}} <
          ({{#time:n|10 hours}} > 10 or  {{#time:n|10 hours}} < 4)
+
  {{#time:YmdHi|{{#time:Y|{{{2|}}}}}0407-{{#time:w|{{#time:Y|{{{2|}}}}}0407}}days-{{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=7|AET|AEST|AEDT=8}}hours-{{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=30|AET|AEST|AEDT=0}}minutes}} or
      <!--date in October after start DST-->
+
  {{#time:YmdHi|{{#time:Y|{{{2|}}}}}1007-{{#time:w|{{#time:Y|{{{2|}}}}}1007}}days-{{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=7|AET|AEST|AEDT=8}}hours-{{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=30|AET|AEST|AEDT=0}}minutes}} <=
        or ({{#time:n|10 hours}} = 10 and {{#time:j|10 hours}} > {{#expr:(7 - (5*{{#time:Y}}/4 + 5) mod 7)}})
+
   {{#time:YmdHi|{{{2|}}}}}
      <!--date in April before end DST-->
 
        or ({{#time:n|10 hours}} = 4  and {{#time:j|10 hours}} < {{#expr:(7 - (5*{{#time:Y}}/4 + 4) mod 7)}})
 
      <!--day of start DST after 2 AM local standard time (first Sunday in October)-->
 
        or ({{#time:n|10 hours}} = 10 and {{#time:j|10 hours}} = {{#expr:(7 - (5*{{#time:Y}}/4 + 5) mod 7)}} and {{#time:G|10 hours {{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=-30|0}} minutes}} >= 2)
 
      <!--day of end DST before 3 AM local daylight saving time, or 2 AM local standard time (first Sunday in April)-->
 
        or ({{#time:n|10 hours}} = 4  and {{#time:j|10 hours}} = {{#expr:(7 - (5*{{#time:Y}}/4 + 4) mod 7)}} and {{#time:G|10 hours {{#switch:{{uc:{{{1}}}}}|ACT|ACST|ACDT=-30|0}} minutes}} < 2)
 
   |1 <!--DST active-->
 
  |0 <!--DST not active-->
 
 
  }}
 
  }}
  
Line 117: Line 82:
 
<!--New Zealand Time-->
 
<!--New Zealand Time-->
 
|NZT|NZST|NZDT=
 
|NZT|NZST|NZDT=
  {{#ifexpr:
+
  {{#expr:
      <!--October through March-->
+
  {{#time:YmdH|{{{2|}}}}} <
          ({{#time:n|12 hours}} > 9 or  {{#time:n|12 hours}} < 4)
+
  {{#time:YmdH|{{#time:Y|{{{2|}}}}}0407-{{#time:w|{{#time:Y|{{{2|}}}}}0407}}days-10hours}} or
      <!--date in September after start DST-->
+
  {{#time:YmdH|{{#time:Y|{{{2|}}}}}0930-{{#time:w|{{#time:Y|{{{2|}}}}}0930}}days-10hours}} <=
        or ({{#time:n|12 hours}} = 9 and {{#time:j|12 hours}} > {{#expr:(30 - (5*{{#time:Y}}/4 + 5) mod 7)}})
+
  {{#time:YmdH|{{{2|}}}}}
      <!--date in April before end DST-->
 
        or ({{#time:n|12 hours}} = 4 and {{#time:j|12 hours}} < {{#expr:(7  - (5*{{#time:Y}}/4 + 4) mod 7)}})
 
      <!--day of start DST after 2 AM local standard time (last Sunday in September)-->
 
        or ({{#time:n|12 hours}} = 9 and {{#time:j|12 hours}} = {{#expr:(30 - (5*{{#time:Y}}/4 + 5) mod 7)}} and {{#time:G|12 hours}} >= 2)
 
      <!--day of end DST before 3 AM local daylight saving time, or 2 AM local standard time (first Sunday in April)-->
 
        or ({{#time:n|12 hours}} = 4 and {{#time:j|12 hours}} = {{#expr:(7  - (5*{{#time:Y}}/4 + 4) mod 7)}} and {{#time:G|12 hours}} < 2)
 
  |1 <!--DST active-->
 
  |0 <!--DST not active-->
 
 
  }}
 
  }}
  

Revision as of 21:07, 6 April 2018

0

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

This template returns either 0 or 1 to indicate if daylight saving time (DST) is active in the given time zone region:

 0  DST is not active
 1  DST is active

See below for the currently supported time zones. Note that if DST is only partially observed in a certain time zone, this template returns 1 if DST is active in that part (even though it is not observed/active in the other part).

During DST, the clock is set one hour ahead of standard time.

Usage

{{Daylight saving in time zone | time zone abbreviation | date/time value}}

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
time zone abbreviation1

Abbreviation of the time zone for which it is determined if DST is active. If no time zone is given or if the given time zone is not supported, then the output will default to 0.

Example
CET
Stringsuggested
date/time value2

Date and time for which it is determined if DST would be active in the given time zone. By default, if no value is given, it is determined if DST is active at the current time.

Example
6 April 2018 23:00 CET
Dateoptional

Supported time zones

From the list of time zone abbreviations, the following time zones are currently supported:

SDT - Abbreviations - DST Name SDT - Script error: No such module "Purge". - DST Notes
HST Hawaii Standard Time UTC−10:00 The *T, *ST and *DT variants of a particular time zone are considered the same region and will produce the same output, thus they can be used interchangeably.

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

More details on the implementation→

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 Both the GMT and BST variants of this time zone are considered the same region and will produce the same output, thus they can be used interchangeably.

This time zone is essentially the same as WET/WEST, see below for more details.

WET WEST Western European (Summer) Time UTC+00:00 UTC+01:00 Both the *ET and *EST variants of a particular time zone are considered the same region and will produce the same output, thus they can be used interchangeably.

More details on the implementation→

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 The *T, *ST and *DT variants of a particular time zone are considered the same region and will produce the same output, thus they can be used interchangeably.

DST is not observed in the AWT time zone.

More details on the implementation→

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.
JST Japan Standard Time UTC+09:00
NZT or NZST NZDT New Zealand Standard/Daylight Time UTC+12:00 UTC+13:00 The NZT, NZST and NZDT variants of this time zone are considered the same region and will produce the same output, thus they can be used interchangeably.

More details on the implementation→

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.)


*{{Daylight saving in time zone|CET}}

produces

  • 0


*{{Daylight saving in time zone|CEST}}

produces

  • 0


*{{Daylight saving in time zone|PT}}

produces

  • 0


*{{Daylight saving in time zone|ACT}}

produces

  • 1


*{{Daylight saving in time zone|NZT}}

produces

  • 1


*{{Daylight saving in time zone|ET|10 March 2018 10:00 EST}}

produces

  • 0


*{{Daylight saving in time zone|ET|11 March 2018 4:50 EST}}

produces

  • 1


*{{Daylight saving in time zone|ET|11 March 2018 4:50}}

produces

  • 0

Related templates

Current time

Current offset

Daylight savings