473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Checking for daylight saving

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
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. If any of their
time zones differs from the epoch then either:

true - daylight saving is being observed on the date, or

false - daylight saving is observed but not on the date

are returned. If no difference is found, undefined is returned. I
explicitly return undefined as a matter of style rather than let the
loop peter out and return undefined by default.

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.

As far as I know, there isn't anywhere that does that, but they might
be accommodated by an "acceptable range" test (say allow changes of up
to 5 minutes) and checking for symmetry - if the time zone is
different in x months time, check if it was also different (12 - x)
months ago, and check if it differed by the same amount taking into
consideration the acceptable range.
function checkDST(d) {

d = d || new Date();

var x = new Date(d);
var dt = d.getTimezoneOffset();
var xt;

for (var i=0; i<3; i++) {
x.setMonth(x.getMonth() + 3)
xt = x.getTimezoneOffset();

if (dt != xt) {
return dt < xt;
}
}
return undefined;
}

function showDST(){

var x = isDST(new Date());
var msg;

if (x === true) {
msg = 'Daylight saving is observed here ' +
'and is in force.';
} else if (x === false) {
msg = 'Daylight saving is observed here, ' +
'but not at the moment.';
} else {
msg = 'Daylight saving is not observed here at all.'
}
alert(x + ': ' + msg);
}

showDST();

--
Rob
Dec 20 '07 #1
27 6717
RobG said the following on 12/20/2007 1:27 AM:

<snip>
function checkDST(d) {
<snip>
function showDST(){

var x = isDST(new Date());
isDST is not defined. FF2.0
Object Expected. IE7.

Long day today?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 20 '07 #2
On Dec 20, 4:45 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
RobG said the following on 12/20/2007 1:27 AM:

<snip>
function checkDST(d) {

<snip>
function showDST(){
var x = isDST(new Date());
That should of course be:

var x = checkDST(new Date());
>
isDST is not defined. FF2.0
Object Expected. IE7.

Long day today?
:-x bugger...
I changed the name of the function just before posting - does it work
for you? I can't mess with my regional settings for a little while
yet, I'll test it more when I can.
--
Rob

Dec 20 '07 #3
RobG said the following on 12/20/2007 2:01 AM:
On Dec 20, 4:45 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>RobG said the following on 12/20/2007 1:27 AM:

<snip>
>>function checkDST(d) {
<snip>
>>function showDST(){
var x = isDST(new Date());

That should of course be:

var x = checkDST(new Date());
I changed the name of the function.
>isDST is not defined. FF2.0
Object Expected. IE7.

Long day today?

:-x bugger...
I changed the name of the function just before posting - does it work
for you? I can't mess with my regional settings for a little while
yet, I'll test it more when I can.
I tested it for about 5 minutes fooling with the date on my computer. I
never did change any time zone settings. I can only tell you that it got
it right for my location.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 20 '07 #4
Response to Randy Webb <Hi************@aol.com>:
I tested it for about 5 minutes fooling with the date on my
computer. I never did change any time zone settings. I can only
tell you that it got it right for my location.
I don't suppose something like this would help?

<URL: http://www.nirsoft.net/utils/run_as_date.html>

....most likely not, but it came to mind.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Dec 20 '07 #5
-Lost said the following on 12/20/2007 3:41 AM:
Response to Randy Webb <Hi************@aol.com>:
>I tested it for about 5 minutes fooling with the date on my
computer. I never did change any time zone settings. I can only
tell you that it got it right for my location.

I don't suppose something like this would help?

<URL: http://www.nirsoft.net/utils/run_as_date.html>

...most likely not, but it came to mind.
Not for what Rob is wanting to test. The only way to know if it is
getting it correct in different time zones is to change the time zone
settings. It is just as trivial to do that for testing as changing the
time/date. I just didn't do it when I was testing. Right click the clock
on the taskbar in Windows>Adjust Date and Time>Time Zone tab. Change it,
apply it, test it, repeat. There is also a setting there for
automatically changing the time for DST. With it unchecked, the test
gives incorrect results for me when testing my own time zone.

"undefined: Daylight saving is not observed here at all. "

And that is in Eastern Standard Time Zone in the US.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 20 '07 #6
Randy Webb wrote on 20 dec 2007 in comp.lang.javascript:
Not for what Rob is wanting to test. The only way to know if it is
getting it correct in different time zones is to change the time zone
settings. It is just as trivial to do that for testing as changing the
time/date. I just didn't do it when I was testing. Right click the
clock on the taskbar in Windows>Adjust Date and Time>Time Zone tab.
Change it, apply it, test it, repeat. There is also a setting there
for automatically changing the time for DST. With it unchecked, the
test gives incorrect results for me when testing my own time zone.

"undefined: Daylight saving is not observed here at all. "

And that is in Eastern Standard Time Zone in the US.
This should work, IMHO:

<script type='text/javascript'>

var d1 = new Date(2007,0,1).getTimezoneOffset()
var d2 = new Date(2007,6,1).getTimezoneOffset()

var t = 'This computer is set for a zone with'

if (d1==d2)
alert(t + 'out summertime offset');
else if (d1>d2)
alert(t + ' summertime offset in Northern hemisphere');
else
alert(t + ' summertime offset in Southern hemisphere');

</script>

IE7 and Central European Time Zone tested.

That such offset saves daylight is absolute nonsense,
though it may save energy consumption.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 20 '07 #7
Evertjan. said the following on 12/20/2007 4:59 PM:
Randy Webb wrote on 20 dec 2007 in comp.lang.javascript:
>Not for what Rob is wanting to test. The only way to know if it is
getting it correct in different time zones is to change the time zone
settings. It is just as trivial to do that for testing as changing the
time/date. I just didn't do it when I was testing. Right click the
clock on the taskbar in Windows>Adjust Date and Time>Time Zone tab.
Change it, apply it, test it, repeat. There is also a setting there
for automatically changing the time for DST. With it unchecked, the
test gives incorrect results for me when testing my own time zone.

"undefined: Daylight saving is not observed here at all. "

And that is in Eastern Standard Time Zone in the US.

This should work, IMHO:

<script type='text/javascript'>

var d1 = new Date(2007,0,1).getTimezoneOffset()
var d2 = new Date(2007,6,1).getTimezoneOffset()

var t = 'This computer is set for a zone with'

if (d1==d2)
alert(t + 'out summertime offset');
else if (d1>d2)
alert(t + ' summertime offset in Northern hemisphere');
else
alert(t + ' summertime offset in Southern hemisphere');

</script>

IE7 and Central European Time Zone tested.
It tells me I have a summertime offset in Northern hemisphere, but, it
doesn't tell me whether I use Daylight Savings Time or not. No setting
on the PC can either. Arizona, USA, is split on DST. Parts of the state
use it and parts don't. Indiana was another state that just recently
started using it.
That such offset saves daylight is absolute nonsense,
though it may save energy consumption.
It doesn't "save daylight", it just changes the hours in the day when it
is there. Personally, I wish they would just do away with the entire
concept as it is a broken phenomenon now.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 21 '07 #8
Response to Randy Webb <Hi************@aol.com>:
>That such offset saves daylight is absolute nonsense,
though it may save energy consumption.

It doesn't "save daylight", it just changes the hours in the day
when it is there. Personally, I wish they would just do away with
the entire concept as it is a broken phenomenon now.
Same here. Halfway through the week (this past DST change) we kept
wondering why no one updated their clocks and come to find out we were
the dummies.

Why in the world did Congress or whoever change that at the last moment
anyway?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Dec 21 '07 #9
Response to Randy Webb <Hi************@aol.com>:
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.
Or double-click.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Dec 21 '07 #10
-Lost said the following on 12/20/2007 9:24 PM:
Response to Randy Webb <Hi************@aol.com>:
>>That such offset saves daylight is absolute nonsense,
though it may save energy consumption.
It doesn't "save daylight", it just changes the hours in the day
when it is there. Personally, I wish they would just do away with
the entire concept as it is a broken phenomenon now.

Same here. Halfway through the week (this past DST change) we kept
wondering why no one updated their clocks and come to find out we were
the dummies.

Why in the world did Congress or whoever change that at the last moment
anyway?
<shrugWhy do politicians do any of the things they do?

One reason I read (and don't know if it is true or not) is:

A new law to extend DST to the first Sunday in November will take effect
in 2007, with the purpose of providing trick-or-treaters more light and
therefore more safety from traffic accidents.

Go figure.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 21 '07 #11
Response to Randy Webb <Hi************@aol.com>:
>Why in the world did Congress or whoever change that at the last
moment anyway?

<shrugWhy do politicians do any of the things they do?
Heh, fair point.
One reason I read (and don't know if it is true or not) is:

A new law to extend DST to the first Sunday in November will take
effect in 2007, with the purpose of providing trick-or-treaters
more light and therefore more safety from traffic accidents.

Go figure.
Well, anything to make us think they care I suppose.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Dec 21 '07 #12
Randy Webb wrote on 21 dec 2007 in comp.lang.javascript:
-Lost said the following on 12/20/2007 9:24 PM:
>Why in the world did Congress or whoever change that at the last moment
anyway?
What congress?

Do you mean 'congress' in the sense of the Kamasutra
and changing a stand of such congress at the last moment?

Wouldn't that put you off, Lost?
<shrugWhy do politicians do any of the things they do?

One reason I read (and don't know if it is true or not) is:

A new law to extend DST to the first Sunday in November will take effect
in 2007, with the purpose of providing trick-or-treaters more light and
therefore more safety from traffic accidents.
What law?

Is that what politicians do, Randy, changing a stand at the last moment?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 21 '07 #13
Evertjan. said the following on 12/21/2007 3:43 AM:
Randy Webb wrote on 21 dec 2007 in comp.lang.javascript:
>-Lost said the following on 12/20/2007 9:24 PM:
>>Why in the world did Congress or whoever change that at the last moment
anyway?

What congress?
You have been reading too much JRS.
Do you mean 'congress' in the sense of the Kamasutra
and changing a stand of such congress at the last moment?

Wouldn't that put you off, Lost?
No, not Kamasutra, it was the World Congress of Politicians.
><shrugWhy do politicians do any of the things they do?

One reason I read (and don't know if it is true or not) is:

A new law to extend DST to the first Sunday in November will take effect
in 2007, with the purpose of providing trick-or-treaters more light and
therefore more safety from traffic accidents.

What law?
The one that extended DST to the first Sunday in November in the USA.
Is that what politicians do, Randy, changing a stand at the last moment?
I am not even sure that politicians know what politicians do. I do know
they can screw up something that should be trivially simple.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 21 '07 #14
Randy Webb wrote on 21 dec 2007 in comp.lang.javascript:
It should. It has a setting to let Windows change the time for you. By
law, in the USA, it always starts and ends on the same days every
year, no matter what zone you are in in the USA, if you use it.
That gives two nights that this offset is rippling though your continent,
and must be terrible for large organisations like radio/tv.

The European law switching at the same time across all timezones is
slightly better.
>Does the London local setting know about the "double summertime" of
WWII?

No idea.
In general, MS-windows zones surely cannot fill in the historical patchwork
of summertime regions.

<http://en.wikipedia.org/wiki/Daylight_saving_time>
points to an European viewpoint:

Guess whose!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 21 '07 #15
In comp.lang.javascript message <xJ*********************@giganews.com>,
Thu, 20 Dec 2007 14:15:01, Randy Webb <Hi************@aol.composted:
>
Not for what Rob is wanting to test. The only way to know if it is
getting it correct in different time zones is to change the time zone
settings.
But can one be certain, in Windows, that such a temporary change cannot
possibly have a lasting adverse effect, such as but not limited to
entries in calendar/diary software and limited-duration software that
looks for time reversal or performing scheduled activity?
It is just as trivial to do that for testing as changing the
time/date. I just didn't do it when I was testing. Right click the
clock on the taskbar in Windows>Adjust Date and Time>Time Zone tab.
Change it, apply it, test it, repeat. There is also a setting there for
automatically changing the time for DST. With it unchecked, the test
gives incorrect results for me when testing my own time zone.

"undefined: Daylight saving is not observed here at all. "

And that is in Eastern Standard Time Zone in the US.
Well, if DST is turned off one must expect it not to be found.
Obviously great care must be taken with the wording of such messages.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Dec 21 '07 #16
Dr J R Stockton said the following on 12/21/2007 7:58 AM:
In comp.lang.javascript message <xJ*********************@giganews.com>,
Thu, 20 Dec 2007 14:15:01, Randy Webb <Hi************@aol.composted:
>Not for what Rob is wanting to test. The only way to know if it is
getting it correct in different time zones is to change the time zone
settings.

But can one be certain, in Windows, that such a temporary change cannot
possibly have a lasting adverse effect, such as but not limited to
entries in calendar/diary software and limited-duration software that
looks for time reversal or performing scheduled activity?
Guess it would depend on how the software was doing the checks. I have
never run into a problem temporarily changing my clock/TZ settings and
then setting them back. But, I don't do anything but quick tests while
they are changed.
>It is just as trivial to do that for testing as changing the
time/date. I just didn't do it when I was testing. Right click the
clock on the taskbar in Windows>Adjust Date and Time>Time Zone tab.
Change it, apply it, test it, repeat. There is also a setting there for
automatically changing the time for DST. With it unchecked, the test
gives incorrect results for me when testing my own time zone.

"undefined: Daylight saving is not observed here at all. "

And that is in Eastern Standard Time Zone in the US.

Well, if DST is turned off one must expect it not to be found.
I didn't turn of DST, all I did was tell Windows not to automatically
set my clock back.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 21 '07 #17
Evertjan. wrote:
Randy Webb wrote on 20 dec 2007 in comp.lang.javascript:
>Not for what Rob is wanting to test. The only way to know if it is
getting it correct in different time zones is to change the time zone
settings.[snip]
Ok - so you *do* all know this is a waste of time don't you? There is
one and only one way to do it. You get the user to state explicitly
what time zone they are in, then you check the *actual* date and time
in that time zone (not the one on the PC - so you will need a remote
time-server somewhere) and then you apply the rules in force in that
specific time zone.

And anyone who wants to do that in Javascript is completely insane!

You have one - count them - *one* choice only. Find a way to ask the
operating system and presume the operating system has the time zone
details *and* rules set as the user wants them. Then check a remote
time-server. Even then, it may not be correct because, of course, the
user may choose to set his or her PC to - let's say - GMT because he
likes to do amateur astronomy and it makes it easier.
Dec 21 '07 #18
In comp.lang.javascript message <MJ*********************@giganews.com>,
Thu, 20 Dec 2007 22:49:47, Randy Webb <Hi************@aol.composted:
>-Lost said the following on 12/20/2007 9:24 PM:
>Response to Randy Webb <Hi************@aol.com>:
>>>That such offset saves daylight is absolute nonsense,
though it may save energy consumption.
It doesn't "save daylight", it just changes the hours in the day
when it is there. Personally, I wish they would just do away with
the entire concept as it is a broken phenomenon now.
Same here. Halfway through the week (this past DST change) we kept
wondering why no one updated their clocks and come to find out we were
the dummies.
Why in the world did Congress or whoever change that at the last
moment anyway?

<shrugWhy do politicians do any of the things they do?

One reason I read (and don't know if it is true or not) is:

A new law to extend DST to the first Sunday in November will take
effect in 2007, with the purpose of providing trick-or-treaters more
light and therefore more safety from traffic accidents.

You can find the exact wording on the Web at a USG-type site.
You can find the URL of it in my <uksumtim.htm>, where you can also find
the exact words in a format similar to that of USG.

Try putting congress daylight saving H.R.6 in an IE address bar and
then using Go .

Did you know that the next day on which a Congressional, but not a
Presidential, election will be held in the USA will be (except maybe in
Arizona and Hawaii) in Summer Time?

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Dec 21 '07 #19
In comp.lang.javascript message <Fo*********************@giganews.com>,
Fri, 21 Dec 2007 05:22:22, Randy Webb <Hi************@aol.composted:
>Evertjan. said the following on 12/21/2007 3:33 AM:
>Randy Webb wrote on 21 dec 2007 in comp.lang.javascript:
>>>IE7 and Central European Time Zone tested.
It tells me I have a summertime offset in Northern hemisphere, but, it
doesn't tell me whether I use Daylight Savings Time or not. No setting
on the PC can either. Arizona, USA, is split on DST. Parts of the
state use it and parts don't. Indiana was another state that just
recently started using it.
Do you mean if you are using summertime offset at present?

No, whether the location I am in observes Daylight Savings Time. If you
look in Windows XP (not sure what other Win OS'es have it), in the Date
and Time Properties>Time Zone tab, there is an explicit setting for
Indiana(East). That is because Indiana, USA did not use DST for a long
time. You won't find a setting for Arizona, USA, in that list. Yet,
there are parts of Arizona that do, and parts that do not, use Daylight
Savings Time. Yet, the Time Zone is the same whether they use it or
not. The OS has no way of knowing that.
There is no way of telling the exact location, so in Arizona it cannot
as supplied know whether the location has DST or not. That is why
there's a checkbox in XP for turning it on & off.

Windows, if MS does its job right (Win98 got it wrong) knows current UK
Summer Time rules, and has checked the box in installation If I uncheck
it, the machine will show UT (GMT) permanently, as it would if I set
Reykjavik.

>How would it be "even more terrible" if there were no such thing as
Daylight Savings Time?
>Does it know when this summertime concept started in each zone?

It should.
It does not; except that Vista can know of the most recent change, which
*could* be when it was first used in a location (not a zone). Labrador
and Chile are in the same time zone; but would use opposite Summer Time
changes.
It has a setting to let Windows change the time for you. By law, in
the USA, it always starts and ends on the same days every year, no
matter what zone you are in in the USA, if you use it.
The same days? The dates vary, being 0-6 days before -03-14 &-11-07.
They're (very probably) not even always the same ISO 8601 yyyy-Www-d
(there will be 2 possible values for ww).
>Does the London local setting know about the "double summertime" of WWII?
It will not; and if it did Javascript would not be allowed to use that
unless the system date was set back to WWII.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Dec 21 '07 #20
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Fri, 21 Dec 2007 17:17:00, Evertjan. <ex**************@interxnl.net>
posted:
>Randy Webb wrote on 21 dec 2007 in comp.lang.javascript:
>It should. It has a setting to let Windows change the time for you. By
law, in the USA, it always starts and ends on the same days every
year, no matter what zone you are in in the USA, if you use it.
Canada is more liberal there; the provinces decide. AFAIK they've
"always" used the US dates, but with some variation in time.

>That gives two nights that this offset is rippling though your continent,
and must be terrible for large organisations like radio/tv.
AIUI, they have comparatively little of that sort of thing. However,
the Russians, with 11(?) zones, know what to do; and likewise the
Australians, if they ripple-change.

There'll be problems when all of Russia joins the EU; either there'll be
a break-in-system, or in Kamchatka they'll change clocks after Monday
breakfast.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Dec 21 '07 #21
In comp.lang.javascript message <lv*********************@giganews.com>,
Thu, 20 Dec 2007 20:59:05, Randy Webb <Hi************@aol.composted:
>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
<rg***@iinet.net.auposted:
>>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.
If you lie to your machine, you must be ready to receive lies back. Rob
may need more subtle wording.
>>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.
Yes, and that power did not change.

I know of no US legislation on the date at which a location can change
from one rule set to another, as (much of?) Indiana did. H.R.6
stipulated 2007-03-01, maybe without fullest consideration.
>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.

Yes, but that's merely another route to the same settings.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Dec 21 '07 #22
Dr J R Stockton said the following on 12/21/2007 5:24 PM:
In comp.lang.javascript message <lv*********************@giganews.com>,
Thu, 20 Dec 2007 20:59:05, Randy Webb <Hi************@aol.composted:
>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
<rg***@iinet.net.auposted:
>>>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.

If you lie to your machine, you must be ready to receive lies back. Rob
may need more subtle wording.
I didn't lie to my machine. I simply told it not to automatically change
the time. I didn't tell it to ignore Daylight Savings Time. If the
checkbox were labeled "Use Daylight Savings Time" then it would be more
indicative of what the user wanted. I still wouldn't be lying to the
machine though.

<snip>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 22 '07 #23
Dr J R Stockton wrote on 21 dec 2007 in comp.lang.javascript:
>>That gives two nights that this offset is rippling though your continent,
and must be terrible for large organisations like radio/tv.

AIUI, they have comparatively little of that sort of thing. However,
the Russians, with 11(?) zones, know what to do; and likewise the
Australians, if they ripple-change.

There'll be problems when all of Russia joins the EU; either there'll be
a break-in-system, or in Kamchatka they'll change clocks after Monday
breakfast.
Not having to get out of bed is such cold places could be a bonus,
someyears I did the same.

What about Vladiwostok?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 22 '07 #24
In comp.lang.javascript message <iu*********************@giganews.com>,
Fri, 21 Dec 2007 13:51:12, Randy Webb <Hi************@aol.composted:
>I didn't turn of DST, all I did was tell Windows not to automatically
set my clock back.

That is what the label said. It is not necessarily what it ought to
have said.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

Dec 22 '07 #25
Dr J R Stockton said the following on 12/22/2007 12:27 PM:
In comp.lang.javascript message <iu*********************@giganews.com>,
Fri, 21 Dec 2007 13:51:12, Randy Webb <Hi************@aol.composted:
>I didn't turn of DST, all I did was tell Windows not to automatically
set my clock back.


That is what the label said. It is not necessarily what it ought to
have said.
And I agree with that. But, changing it is not lying to the machine.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 22 '07 #26
Dr J R Stockton wrote on 22 dec 2007 in comp.lang.javascript:
I occasionally, as you may have noticed, change pieces of my date code
from local to UTC.
I think, as you may have guessed, that JS Date()'s UTC support is a mess.

It would have been better to have all methods have a attribute
having them interact directly with the internal UTC date/time value of
any Date() object.

dateObj.getDate('UTC')
in stead of
dateObj.getUTCDate()
etc.

That way we could define functions,
that would work both for local time as for UTC:

function manipulateTimeDate(myDate,UTCorNot) {
.....;
.....;
return myDate.getUTCDate(UTCorNot);
};

var nrDate = manipulateTimeDate(thatDate);

var UTCnrDate = manipulateTimeDate(thatDate,'UTC');

====================================

btw, ever replied upon this in MS scripting 5.6?

===========
dateObj.getVarDate()

Remarks
The required dateObj reference is a Date object.

The getVarDate method is used when interacting with COM objects, ActiveX®
objects or other objects that accept and return date values in VT_DATE
format, such as Visual Basic and VBScript.

The actual format is dependent on regional settings and should not be
replied upon within JScript.
============

"replied upon" ??

MS-JS being unreplyable, MS seems to have a lot to answer for.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 23 '07 #27
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Sun, 23 Dec 2007 08:51:54, Evertjan. <ex**************@interxnl.net>
posted:
>Dr J R Stockton wrote on 22 dec 2007 in comp.lang.javascript:
>I occasionally, as you may have noticed, change pieces of my date code
from local to UTC.

I think, as you may have guessed, that JS Date()'s UTC support is a mess.

It would have been better to have all methods have a attribute
having them interact directly with the internal UTC date/time value of
any Date() object.
Or maybe for every Date Object to have a property that made it work
either in UTC or in LCT?
>That way we could define functions,
that would work both for local time as for UTC:
Note that an algorithm correct for all LCT is correct for UTC (because
sometimes LTC is UTC), but an algorithm correct for UTC is not
necessarily correct for all LTC.

>dateObj.getVarDate()
I know it exists in IE6 & IE7, but I've never investigated what it is
for. <js-date0.htmrefers.
>"replied upon" ??
Indeed - relied upon?
Opera is 9.25.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Dec 23 '07 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Amitabh Deepak | last post by:
Is there any way to check whether daylight saving is enabled on a linux machine?
1
by: Drew | last post by:
Is there a way to check if it is daylight savings or not via c#? I have heard you can use System.Globalization? Thanks - Drew
7
by: Brett Edman | last post by:
I created a UTC clock using this: UTCTime = MyTime.ToUniversalTime() Now that we've turned the clocks ahead 1 hour for daylight savings time, the clock is reporting the wrong UTC time. It is...
6
by: Robm | last post by:
Since googling this issue only brings up the April fool's problem, which was solved years ago, I hope that somebody can help me with this. I have a large vc++/mfc application which needs to know...
0
by: Chirag Shukla | last post by:
Colleagues, I wanted to share a function to find if a date is in Daylight Saving Time or not. I was able to make this function faster than reading MSDN to find functions that .NET provides. I...
1
by: maflatoun | last post by:
Hi everyone, I have 3 different time zones that I'm working with. Basically converting from UTC to those 3 time zones. Eastern Daylight Time (GMT -04:00, New York) Central Daylight Time (GMT...
1
by: maflatoun | last post by:
Hi everyone, I have 3 different time zones that I'm working with. Basically converting from UTC to those 3 time zones. Eastern Daylight Time (GMT -04:00, New York) Central Daylight Time (GMT...
1
by: luke_airig | last post by:
I'm not sure if this is the right group for this posting. If not, please accept my apologies. I have been tasked with identifying and correcting application code that will be affected by the...
2
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, My app picks ccurrent time on the PC to retrieve data from sql DB, the Sql data is always data with non-daylight saving. The app runs on PC with both daylight saving and non-daylight...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.