Re: Checking for daylight saving
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Thu, 20 Dec 2007 20:59:05 -0500
Dr J R Stockton said the following on 12/20/2007 5:40 PM:
In comp.lang.javascript message <ecae4e75-9e61-4aa0-90ab-6c10978d781e@d4
g2000prg.googlegroups.com>, Wed, 19 Dec 2007 22:27:46, RobG
<rgqld@xxxxxxxxxxxx> posted:
I was investigating a function to determine whether daylight saving^^^^^^^^^^
was being observed on a particular date (given the platform's regional
settings) and came across a suggestion at merlyn.com to test the time
I have "American" competition?
zone offset on a variety of dates to see if it changes. Based on
that, I developed the following checkDST() function which, as far as I
can tell, should be sufficient.
It checks either the date passed to it or the current date with 3
other dates, each 3 months further into the future.
Checking the date in question, and January 1st, and July 1st, should
suffice - unless someone does something silly with Summer Time.
It doesn't take anything that naive to fool it. Simply telling my PC not to change the time for me is enough to cause Rob's function to give incorrect results.
ISTR that Australia fiddled the rules for the Olympics, but probably not
enough to matter.
Can anyone suggest whether the algorithm is appropriate and if my
implementation is OK? It will fail if there are changes to time zone
offsets that are not related to daylight saving, and if changes occur
for a period of less than 3 months and fall within the dates tested.
ISO/IEC 16262 requires that the CURRENT Summer Time rules are applied
for ALL years. Most OSs only know one set of rules per location, but
AIUI Vista knows up to 2 sets, and changes.
US legislation, IIRC, changed the rules with effect from 2007-03-01
(presumably local time; possibly DC time). Therefore, Randy et al
should have stopped running Javascript on pre-Vista PCs before
2007-02-28 24:00 LCT, should have updated their systems, and not
restarted Javascript before 2007-03-01 00:00 LCT.
What US legislation also does is make it a local decision as to whether it is used or not. Witness Arizona in the USA.
I don't know whether Vista does it right.
Some systems, IIRC, using UNIX, get the OS to do date work that
Javascript ought to do; in that case, the wrong (by 16262) rules or zone
may be applied to non-current dates.
I recall no provision for changing time zone at a location, other than
by the Control Panel settings.
You can get to it without going into the Control Panel but it changes it in the same place. Right click the clock on the Windows Taskbar>Adjust Date/Time.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.
- Follow-Ups:
- Re: Checking for daylight saving
- From: Dr J R Stockton
- Re: Checking for daylight saving
- From: -Lost
- Re: Checking for daylight saving
- References:
- Checking for daylight saving
- From: RobG
- Re: Checking for daylight saving
- From: Dr J R Stockton
- Checking for daylight saving
- Prev by Date: Re: Checking for daylight saving
- Next by Date: Re: Datejs - A JavaScript Date Library
- Previous by thread: Re: Checking for daylight saving
- Next by thread: Re: Checking for daylight saving
- Index(es):
Relevant Pages
|