Daylight Saving Time

G

geolev

I'm trying to understand the effects of the Daylight Saving Time rule
changes for 2007 in the US. Can anyone tell me how Javascript knows
when to apply Daylight Saving Time in the following script?

d1 = new Date(2006, 03, 01, 23, 00);
d2 = new Date(2006, 03, 02, 04, 00);
// Reports "This is ok: The answere should be 4. It is 4".
alert("This is ok: The answer should be 4. It is " + (((d2.valueOf()
- d1.valueOf())/1000)/60)/60);

Nowhere did I tell it that I was on the east coast and that DST
applies. How did Javascript know to make the expected adjustment?

Thanks,
George
 
E

Evertjan.

geolev wrote on 16 aug 2006 in comp.lang.javascript:
Nowhere did I tell it that I was on the east coast and that DST
applies. How did Javascript know to make the expected adjustment?

You did, when you installed Windows, and perhaps changed it later.

Your time zone and the DST area are set in Windows,
and javascript just gets the local time [rules] from there.

I suppose MS will send you/us local changes in an update.
 
G

geolev

Ah. I guess that was my real question.

The browser must call an OS API to determine the TZ and whether DST
applies. Then the browser must make this available to the Javascript
engine.

Can anyone confirm that this is indeed how it works?

Thanks Evertjan for the quick response.

geolev

Evertjan. said:
geolev wrote on 16 aug 2006 in comp.lang.javascript:
Nowhere did I tell it that I was on the east coast and that DST
applies. How did Javascript know to make the expected adjustment?

You did, when you installed Windows, and perhaps changed it later.

Your time zone and the DST area are set in Windows,
and javascript just gets the local time [rules] from there.

I suppose MS will send you/us local changes in an update.
 
E

Evertjan.

geolev wrote on 16 aug 2006 in comp.lang.javascript:
Evertjan. said:
geolev wrote on 16 aug 2006 in comp.lang.javascript:
Nowhere did I tell it that I was on the east coast and that DST
applies. How did Javascript know to make the expected adjustment?

You did, when you installed Windows, and perhaps changed it later.

Your time zone and the DST area are set in Windows,
and javascript just gets the local time [rules] from there.

I suppose MS will send you/us local changes in an update.
Ah. I guess that was my real question.

[please do not toppost on usenet]
[please do not include signature in the quote]
The browser must call an OS API to determine the TZ and whether DST
applies. Then the browser must make this available to the Javascript
engine.

Can anyone confirm that this is indeed how it works?

You can easily try it by temporarily changing your timezone settings.

"browser"? javascript/jscript can also work outside the IE-browser,
like in wscript and IIS.

In FF, etc I would not know.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Wed, 16
Aug 2006 16:04:56 remote, seen in Evertjan.
geolev wrote on 16 aug 2006 in comp.lang.javascript:


You did, when you installed Windows, and perhaps changed it later.

Not necessarily. There are other OSs that support Javascript.

Your time zone and the DST area are set in Windows,
and javascript just gets the local time [rules] from there.

That may be more-or-less confirmed by comparing the time taken to do
new Date(2006, 7)
new Date(Date.UTC(2006, 7))
maybe in a local copy of <URL:http://www.merlyn.demon.co.uk/js-
quick.htm> using Demo 5.

The former code needs to know the Summer Time rule; the latter does not.
I find the difference in speed (a factor of over 5) to be too great to
be accounted for by the work of actually applying the rule. Other
browsers may do better.
I suppose MS will send you/us local changes in an update.

By now I'd have expected to be offered many copies of spam/malware
specifically offering to do that - but I've noticed none.


The Javascript spec in ECMA-262 specifies (IIRC) that the current set of
Summer Time rules are applied for every year; therefore, the update
should not be applied too soon.
<URL:http://www.merlyn.demon.co.uk/js-date2.htm#CCD> should show the
dates by current rules for the current year; the code can easily be
changed for other years.

OP : read the newsgroup FAQ.
 
E

Evertjan.

Dr John Stockton wrote on 16 aug 2006 in comp.lang.javascript:
By now I'd have expected to be offered many copies of spam/malware
specifically offering to do that - but I've noticed none.

I do not know how many summertime/dst rules change over the years in the
whole world, John, but as MS in it's Windows OS has a long list of regions,
they [MS] should adapt them somehow to thos rule changes by updating?

The simple user should not and probably cannot do that himself.

"spam/malware" I do not read.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Thu, 17
Aug 2006 07:14:27 remote, seen in Evertjan.
Dr John Stockton wrote on 16 aug 2006 in comp.lang.javascript:
By now I'd have expected to be offered many copies of spam/malware
specifically offering to do that - but I've noticed none.

I do not know how many summertime/dst rules change over the years in the
whole world, John, but as MS in it's Windows OS has a long list of regions,
they [MS] should adapt them somehow to thos rule changes by updating?

The simple user should not and probably cannot do that himself.

When did the Netherlands adopt the present rules? <URL:http://www.merlyn
..demon.co.uk/uksumtim.htm#EU> lacks adoption dates for most EU
countries.

There is, I believe, software to edit the list in Windows easily enough.
Look in your zone setting dialogue, choose a place whose name is
unlikely to occur otherwise, and search C:\windows\ for it - I use
MiniTrue - I expect you'll find system.nav quite soon, unless they've
changed the way they do it. But it's not plaintext. My copy is 211 kB,
seemingly unchanged since installation, so it may well be replaceable
quite simply.

Microsoft in the USA will need to arrange updates, soon after 2006 Nov
4th.

But that's irrelevant for the purposes of malware; ISTM that malware
headed "Update for 2007 DST" would attract the favourable attention of
the more gullible Americans - and according to a very recent article
here in c.l.j there are over 100 billion of them - which proves
conclusively that there is at least one.
"spam/malware" I do not read.

I do see the subjects of what is ready to be downloaded on one afternoon
per week; and I sometimes glance into other items; with Turnpike
newsreader, that is wholly safe.
 
E

Evertjan.

Dr John Stockton wrote on 17 aug 2006 in comp.lang.javascript:
When did the Netherlands adopt the present rules?
<URL:http://www.merlyn .demon.co.uk/uksumtim.htm#EU> lacks adoption
dates for most EU countries.

I think, like the whole of the European Economic Community [called
Common Market in the UK] of 1979, in 1979.

Eighth Directive 97/44/EC of the European Parliament
and of the Council on summer-time arrangements
<http://europa.eu/bulletin/en/9707/p103146.htm>
was approved 22 July 1979.

The last Dutch regulation [1979/488] apeared in the Staatsbad of 1979,
this regulation could just be the ratification of EU one, see:
<http://www.phys.uu.nl/~vgent/wettijd/wt_text4c.htm>

The online Staatsblad
<http://www.overheid.nl/op/index.html>
only starts at 1995,
so I cannot find this 1979/488.

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

These formulas could interest you:
<http://www.phys.uu.nl/~vgent/wettijd/wt_text4d.htm>

[..]
I do see the subjects of what is ready to be downloaded on one
afternoon per week; and I sometimes glance into other items; with
Turnpike newsreader, that is wholly safe.

My Pegasus [in use here since 1995] is safe.

However since most spam/etc is in English, babesian and other filtering
for us Dutch seems far more effective than for English mailing people.

I only now and then glance into my spam folder to recover known "from:"
addresses before deleting. I usually do not look at the subject texts.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Fri, 18
Aug 2006 07:48:02 remote, seen in Evertjan.
Dr John Stockton wrote on 17 aug 2006 in comp.lang.javascript:
When did the Netherlands adopt the present rules?
<URL:http://www.merlyn .demon.co.uk/uksumtim.htm#EU> lacks adoption
dates for most EU countries.

I think, like the whole of the European Economic Community [called
Common Market in the UK] of 1979, in 1979.

The UK used the day after Fourth Saturday in October 1981-1994.

One must discriminate between when each country adopted "Brussels Rules"
and when the present rules started. States in the EU on that date used
present rules from 1995-10-22; but some may already have been using
those.
Eighth Directive 97/44/EC of the European Parliament
and of the Council on summer-time arrangements
<http://europa.eu/bulletin/en/9707/p103146.htm>
was approved 22 July 1979.

1997 != 1979 :-(
The last Dutch regulation [1979/488] apeared in the Staatsbad of 1979,
this regulation could just be the ratification of EU one, see:
<http://www.phys.uu.nl/~vgent/wettijd/wt_text4c.htm>

The online Staatsblad
<http://www.overheid.nl/op/index.html>
only starts at 1995,
so I cannot find this 1979/488.

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

These formulas could interest you:
<http://www.phys.uu.nl/~vgent/wettijd/wt_text4d.htm>

I've seen parts of RHvG's site before, but not that part. Similar
formulae have been in <URL:http://www.merlyn.demon.co.uk/uksumtim.htm#SF>
for some time now.

Dutch is a strange language; when I know what it means, I can usually
tell how it does it. Sometimes I can work out the meaning just by
looking at the words.

Thanks.

.. . .

Does <URL:http://www.merlyn.demon.co.uk/crit-pts.htm> work in non-IE
browsers (i.e. load without error messages, all 3 buttons write to
Result)? Do the results appear correct in locations away from the
Greenwich zone?
 
R

Randy Webb

Dr John Stockton said the following on 8/18/2006 6:02 PM:

Does <URL:http://www.merlyn.demon.co.uk/crit-pts.htm> work in non-IE
browsers (i.e. load without error messages, all 3 buttons write to
Result)?

Firefox: F1 has no properties
It results from:

F1 = document.getElementById("Frm1")

With this HTML:

<form name=Frm1 class=TRY action="#">

IE will resolve gEBI against a NAME attribute, Firefox doesn't.

Opera 9 loads and all 3 buttons work properly.
Do the results appear correct in locations away from the Greenwich zone?

The formatting is skewed for me in Opera 9 although it looks fine in IE.
 
E

Evertjan.

Dr John Stockton wrote on 19 aug 2006 in comp.lang.javascript:
I think, like the whole of the European Economic Community [called
Common Market in the UK] of 1979, in 1979.

The UK used the day after Fourth Saturday in October 1981-1994.

One must discriminate between when each country adopted "Brussels Rules"
and when the present rules started. States in the EU on that date used
present rules from 1995-10-22; but some may already have been using
those.

Wasn't that because the eec/eu changed the general rules?
Or did the uk have different rules
from the eec recommandations for 1981-1994?

1997 != 1979 :-(

;-(((

We should be glad that the EU does not have the North-American "rippling"
rule where each more western zone changes one hour later, making interzone
planning a nightmare on those nights.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Fri, 18 Aug 2006 19:15:02 remote, seen in
Randy Webb said:
Dr John Stockton said the following on 8/18/2006 6:02 PM:



Firefox: F1 has no properties
It results from:

F1 = document.getElementById("Frm1")

With this HTML:

<form name=Frm1 class=TRY action="#">

IE will resolve gEBI against a NAME attribute, Firefox doesn't.

Well, I've changed name=Frm1 to ID=Frm1 and it still works here; I'll
upload. Before I unleash that change site-wide with MiniTrue, does
anyone see any likelihood of it doing harm? Normally I don't use gEBI
with forms.
Opera 9 loads and all 3 buttons work properly.


The formatting is skewed for me in Opera 9 although it looks fine in IE.

Would that be the formatting within a textarea, or of the page as a
whole?

Thanks for looking.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Sat, 19
Aug 2006 07:21:03 remote, seen in Evertjan.
Dr John Stockton wrote on 19 aug 2006 in comp.lang.javascript:
I think, like the whole of the European Economic Community [called
Common Market in the UK] of 1979, in 1979.

The UK used the day after Fourth Saturday in October 1981-1994.

One must discriminate between when each country adopted "Brussels Rules"
and when the present rules started. States in the EU on that date used
present rules from 1995-10-22; but some may already have been using
those.

Wasn't that because the eec/eu changed the general rules?
Or did the uk have different rules
from the eec recommandations for 1981-1994?

Yes and yes, I think.

RHvG's wt_text4c.htm shows zomertijd ending in the last Sunday in
September 1981-1995, then October; but we've used October since 1971 or
earlier. In 1995, the British Isles changed on dates matching the
current rules; but the Netherlands used the old rules for the last time
that year, and it seems that mainland EU agreed with the Netherlands
from at least 1981.
 
R

Randy Webb

Dr John Stockton said the following on 8/19/2006 3:58 PM:
JRS: In article <[email protected]>, dated
Fri, 18 Aug 2006 19:15:02 remote, seen in

Well, I've changed name=Frm1 to ID=Frm1 and it still works here; I'll
upload. Before I unleash that change site-wide with MiniTrue, does
anyone see any likelihood of it doing harm? Normally I don't use gEBI
with forms.

None that I personally am aware of but I don't use gEBI with forms at
all. I always use the forms collection and no worries with it.
Would that be the formatting within a textarea, or of the page as a
whole?

The formatting of the Sorted Result textarea.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Sun, 20 Aug 2006 01:04:51 remote, seen in
Randy Webb said:
Dr John Stockton said the following on 8/19/2006 3:58 PM:
None that I personally am aware of but I don't use gEBI with forms at
all. I always use the forms collection and no worries with it.

That makes more sense. Implemented, with the old code commented out.

The formatting of the Sorted Result textarea.

That should be infallible, if browsers handle Tab in the usual manner
there. Presumably they do not. ISTR that I've had to add a Space(N)
function before. Alas, there seems to be 306 '\t' on my site in 24
files; many may need to be changed.

Fixed, I hope, on that page. Thanks again.


Does anyone have a good routine for expanding tabs to the appropriate
number of spaces in a general string?
 
R

Randy Webb

Dr John Stockton said the following on 8/20/2006 6:34 PM:
JRS: In article <[email protected]>, dated
Sun, 20 Aug 2006 01:04:51 remote, seen in Randy Webb <[email protected]> posted :


That should be infallible, if browsers handle Tab in the usual manner
there. Presumably they do not. ISTR that I've had to add a Space(N)
function before. Alas, there seems to be 306 '\t' on my site in 24
files; many may need to be changed.

Fixed, I hope, on that page. Thanks again.

It appears properly formatted in Opera now so it is fixed on that page.
 
E

Evertjan.

Dr John Stockton wrote on 21 aug 2006 in comp.lang.javascript:
Does anyone have a good routine for expanding tabs to the appropriate
number of spaces in a general string?

Do you mean something like this:

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

<script type='text/javascript'>

function tabber(lines,tabarr){
var result ='',t,tba,res,j,tabl,tabc;
lines = (!lines[0])?[lines]:lines;
for (var i=0;i<lines.length;i++) {
tba = tabarr || [8];
tabc = 0;
tabl = 0;
res = '';
t = lines.split('\t');
for (j=0;j<t.length;j++) {
res += t[j];
tabl += tba[tabc++] || tba[tabc=0];
while (res.length<=tabl) {res += ' ';};
res += ' ';
};
result += res + '<br>';
};
//return result.replace(/ /g,'&nbsp;');
return '<pre>'+result+'</pre>';
};

r = tabber([
'Hello\tWorld\t12345',
'This\tis a\ttest in tabbing'
]);
document.write(r);

r = tabber([
'Hello\tWorld\t12345',
'This\tis a test\tin tabbing'
],
[12,20]
);
document.write(r);

r = tabber('Hi\tthere',[19]);
document.write(r);

</script>

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

Just replacing all \t by <td>, etc. is another option
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Mon, 21
Aug 2006 08:44:58 remote, seen in Evertjan.
Dr John Stockton wrote on 21 aug 2006 in comp.lang.javascript:


Do you mean something like this:

Thanks; that's probably more than a good start.

I'd only want to expand tabs to spaces (putting HTML in could be done in
a wrapper), and I was intending to set tab stops at 8N+1 - but having an
array of tabs could be useful.

It adds spaces at the ends of lines ...
 
E

Evertjan.

Dr John Stockton wrote on 22 aug 2006 in comp.lang.javascript:
Thanks; that's probably more than a good start.

I'd only want to expand tabs to spaces (putting HTML in could be done
in a wrapper), and I was intending to set tab stops at 8N+1 - but
having an array of tabs could be useful.

It adds spaces at the ends of lines ...

Only because my counting was not very well done
and a spurious space was added.

Update:

<script type='text/javascript'>

function tabber(lines,tabarr){
// lines needs one tabbed line or an array of lines
// tabbarray is default [8], or a specified array, ..
// .. and recycles when to short
var result ='',t,tba,res,j,tabl,tabc;
lines = (!lines[0])?[lines]:lines;
for (var i=0;i<lines.length;i++) {
tba = tabarr || [8];
tabc = 0;
tabl = 0;
res = '';
t = lines.split('\t');
for (j=0;j<t.length;j++) {
res += t[j];
tabl += tba[tabc++] || tba[tabc=0];
while (res.length<tabl) {res += ' ';};
};
result += res + '<br>';
};
nm = '1234567890';nm+=nm+nm+nm+'<br>';
// nm = '';
//return result.replace(/ /g,'&nbsp;');
return '<pre>'+nm+result+'</pre>';
};

// =========== testing:

r = tabber([
'Hello\tWorld\t12345',
'This\tis a\ttest in tabbing'
]);
document.write(r);

r = tabber([
'Hello\tWorld\t12345',
'This\tis a test\tin tabbing'
],
[12,20]
);
document.write(r);

r = tabber('Hi\tthere',[19]);
document.write(r);

</script>
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 22
Aug 2006 09:27:28 remote, seen in Evertjan.
Dr John Stockton wrote on 22 aug 2006 in comp.lang.javascript:

Only because my counting was not very well done
and a spurious space was added.

Not entirely. Change the added spaces to underlines to see the effect,
which remains in the revised code (though perhaps less often).

I put, after res += t[j] ,
if (j==t.length-1) break
to avoid adding spacing at the end. I ended up with a
while (1) { ... if..break ... }
loop there.


I went for do { res += " " } while (res.length<tabl)
to ensure that a tab would always give at least one space.

My temporary page $tab.htm is a test for these and for my T8
simplification to take a single string with \n & \t and expand the tabs
to fill up to the next multiple of 8.
// .. and recycles when to short
too



You've prompted discussion with RHvG about our pages : alas, Moose Jaw
had DST in 1912, over 3 years before Shackleton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top