Difference between revisions of "Template:Usdst"

From Geohashing
imported>Tjtrumpet2323
(New page: {{#vardefine:year|{{#time:Y|{{{1|{{CURRENTTIMESTAMP}}}}} }}}}{{#vardefine:remainder|{{#time:mdHi|{{{1|{{CURRENTTIMESTAMP}}}}} }}}}{{#ifexpr: {{#var:year}} <= 2006 | {{#ifexpr: ({{#var:rema...)
 
imported>Tjtrumpet2323
(Usage)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{#vardefine:year|{{#time:Y|{{{1|{{CURRENTTIMESTAMP}}}}} }}}}{{#vardefine:remainder|{{#time:mdHi|{{{1|{{CURRENTTIMESTAMP}}}}} }}}}{{#ifexpr: {{#var:year}} <= 2006
 
{{#vardefine:year|{{#time:Y|{{{1|{{CURRENTTIMESTAMP}}}}} }}}}{{#vardefine:remainder|{{#time:mdHi|{{{1|{{CURRENTTIMESTAMP}}}}} }}}}{{#ifexpr: {{#var:year}} <= 2006
| {{#ifexpr: ({{#var:remainder}} >= {{#expr:04{{weekday in month|{{#var:year}}|4|0|1}}0700}}) and ({{#var:remainder}} < {{#expr:10{{weekday in month|{{#var:year}}|10|0|-1}}0600}}) | 1 | 0}}
+
| {{#expr: ({{#var:remainder}} >= {{#expr:04{{padleft:{{weekday in month|{{#var:year}}|4|0|1}}|2|0}}0700}}) and ({{#var:remainder}} < {{#expr:10{{padleft:{{weekday in month|{{#var:year}}|10|0|-1}}|2|0}}0600}}) }}
| {{#ifexpr: ({{#var:remainder}} >= {{#expr:03{{weekday in month|{{#var:year}}|3|0|2}}0700}}) and ({{#var:remainder}} < {{#expr:11{{weekday in month|{{#var:year}}|11|0|1}}0600}}) | 1 | 0}}
+
| {{#expr: ({{#var:remainder}} >= {{#expr:03{{padleft:{{weekday in month|{{#var:year}}|3|0|2}}|2|0}}0700}}) and ({{#var:remainder}} < {{#expr:11{{padleft:{{weekday in month|{{#var:year}}|11|0|1}}|2|0}}0600}}) }}
 
}}<noinclude>
 
}}<noinclude>
 
== Usage ==
 
== Usage ==
 
{{intricate}}
 
{{intricate}}
<code><nowiki>{{usdst}}</nowiki></code>
+
Returns '''1''' if the United States (specifically its [[Eastern Time|Eastern Time Zone]]) are in [[wikipedia:Daylight Saving Time|Daylight Saving Time]] at the time passed in the parameter, '''0''' if not.
* Returns '''1''' if the United States (specifically its [[Eastern Time|Eastern Time Zone]]) are in [[wikipedia:Daylight Saving Time|Daylight Saving Time]], '''0''' if not.
+
* <code><nowiki>{{usdst}}</nowiki></code> uses the current time stamp.
 +
* <code><nowiki>{{usdst|2008-03-14}}</nowiki></code> considers the DST status at ''00:00 UTC'' on 2008-03-14.  '''Dates must be passed in YYYY-MM-DD format.'''
 +
* <code><nowiki>{{usdst|2006-10-29 06:45}}</nowiki></code> considers the DST status at 06:45 UTC on 2006-10-29.  '''Times must be passed in UTC.'''
 
** From 2007, Daylight Saving Time is observed in the United States from 02:00 local (07:00 UTC) on the second Sunday in March through 02:00 local (06:00 UTC) on the first Sunday in November.
 
** From 2007, Daylight Saving Time is observed in the United States from 02:00 local (07:00 UTC) on the second Sunday in March through 02:00 local (06:00 UTC) on the first Sunday in November.
 +
 +
== Notes ==
 
* For simplicity's sake, this template applies DST rules used from 1987-2006 to all years 1986 and prior.
 
* For simplicity's sake, this template applies DST rules used from 1987-2006 to all years 1986 and prior.
 
* This template currently extends the current (2007) DST rules to all years following.  ''Further DST legislation in the United States may require updates to this template.''
 
* This template currently extends the current (2007) DST rules to all years following.  ''Further DST legislation in the United States may require updates to this template.''
 
</noinclude>
 
</noinclude>

Latest revision as of 05:25, 3 July 2008

0

Usage

Returns 1 if the United States (specifically its Eastern Time Zone) are in Daylight Saving Time at the time passed in the parameter, 0 if not.

  • {{usdst}} uses the current time stamp.
  • {{usdst|2008-03-14}} considers the DST status at 00:00 UTC on 2008-03-14. Dates must be passed in YYYY-MM-DD format.
  • {{usdst|2006-10-29 06:45}} considers the DST status at 06:45 UTC on 2006-10-29. Times must be passed in UTC.
    • From 2007, Daylight Saving Time is observed in the United States from 02:00 local (07:00 UTC) on the second Sunday in March through 02:00 local (06:00 UTC) on the first Sunday in November.

Notes

  • For simplicity's sake, this template applies DST rules used from 1987-2006 to all years 1986 and prior.
  • This template currently extends the current (2007) DST rules to all years following. Further DST legislation in the United States may require updates to this template.