469,284 Members | 2,505 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,284 developers. It's quick & easy.

Daylight Saving Time

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

Aug 16 '06 #1
26 4347
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 16 '06 #2
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. wrote:
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 16 '06 #3
geolev wrote on 16 aug 2006 in comp.lang.javascript:
Evertjan. wrote:
>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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 16 '06 #4
JRS: In article <Xn********************@194.109.133.242>, dated Wed, 16
Aug 2006 16:04:56 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>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.
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.htmusing 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#CCDshould show the
dates by current rules for the current year; the code can easily be
changed for other years.

OP : read the newsgroup FAQ.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 16 '06 #5
Dr John Stockton wrote on 16 aug 2006 in comp.lang.javascript:
>>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.
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 17 '06 #6
JRS: In article <Xn********************@194.109.133.242>, dated Thu, 17
Aug 2006 07:14:27 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>Dr John Stockton wrote on 16 aug 2006 in comp.lang.javascript:
>>>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.

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#EUlacks 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.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/>
Aug 17 '06 #7
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#EUlacks 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/%7Evgent/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>

[..]
>
>>"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.
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.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 18 '06 #8
JRS: In article <Xn********************@194.109.133.242>, dated Fri, 18
Aug 2006 07:48:02 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>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#EUlacks 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/%7Evgent/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.htmwork 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?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 18 '06 #9
Dr John Stockton said the following on 8/18/2006 6:02 PM:

<snip>
Does <URL:http://www.merlyn.demon.co.uk/crit-pts.htmwork 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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 18 '06 #10
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?

>>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 :-(
;-(((

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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 19 '06 #11
JRS: In article <sY******************************@comcast.com>, dated
Fri, 18 Aug 2006 19:15:02 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>Dr John Stockton said the following on 8/18/2006 6:02 PM:

<snip>
>Does <URL:http://www.merlyn.demon.co.uk/crit-pts.htmwork 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.
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.
>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.
Would that be the formatting within a textarea, or of the page as a
whole?

Thanks for looking.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
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.
Aug 19 '06 #12
JRS: In article <Xn********************@194.109.133.242>, dated Sat, 19
Aug 2006 07:21:03 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
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.
Aug 19 '06 #13
Dr John Stockton said the following on 8/19/2006 3:58 PM:
JRS: In article <sY******************************@comcast.com>, dated
Fri, 18 Aug 2006 19:15:02 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>Dr John Stockton said the following on 8/18/2006 6:02 PM:

<snip>
>>Does <URL:http://www.merlyn.demon.co.uk/crit-pts.htmwork 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.

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

Would that be the formatting within a textarea, or of the page as a
whole?
The formatting of the Sorted Result textarea.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 20 '06 #14
JRS: In article <x5******************************@comcast.com>, dated
Sun, 20 Aug 2006 01:04:51 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>Dr John Stockton said the following on 8/19/2006 3:58 PM:
>JRS: In article <sY******************************@comcast.com>, dated
Fri, 18 Aug 2006 19:15:02 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>>Dr John Stockton said the following on 8/18/2006 6:02 PM:

<snip>

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

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

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 20 '06 #15
Dr John Stockton said the following on 8/20/2006 6:34 PM:
JRS: In article <x5******************************@comcast.com>, dated
Sun, 20 Aug 2006 01:04:51 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
<snip>
>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.
It appears properly formatted in Opera now so it is fixed on that page.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 20 '06 #16
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[i].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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 21 '06 #17
JRS: In article <Xn********************@194.109.133.242>, dated Mon, 21
Aug 2006 08:44:58 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>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:
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 ...

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 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.
Aug 21 '06 #18
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[i].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>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 22 '06 #19
JRS: In article <Xn********************@194.109.133.242>, dated Tue, 22
Aug 2006 09:27:28 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>Dr John Stockton wrote on 22 aug 2006 in comp.lang.javascript:
>It adds spaces at the ends of lines ...

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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
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.
Aug 22 '06 #20
Dr John Stockton wrote on 23 aug 2006 in comp.lang.javascript:
My temporary page $tab.htm
Not in here: <http://www.merlyn.demon.co.uk/programs/??

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 23 '06 #21
Dr John Stockton wrote on 23 aug 2006 in comp.lang.javascript:
You've prompted discussion with RHvG about our pages : alas, Moose Jaw
had DST in 1912, over 3 years before Shackleton.
your 1912:

From Mark Brader (2003-07-26):
[According to the Toronto Star] Orillia, Ontario, adopted DST
effective Saturday, 1912-06-22, 22:00; the article mentions that
Port Arthur (now part of Thunder Bay, Ontario) as well as Moose Jaw
have already done so. In Orillia DST was to run until Saturday,
31 (no time mentioned), but it was met with considerable
hostility from certain segments of the public, and was revoked after
only two weeks -- I copied it as Saturday, 1912-07-07, 22:00, but
presumably that should be -07-06. (1912-06-19, -07-12; also letters
earlier in June).

===

Thunder Bay region 1910 "probably"!

<http://sources.redhat.com/ml/libc-alpha/2004-07/msg00169.html>:

# Willett (1914-03) writes (p. 17) "In the Cities of Fort William, and
# Port Arthur, Ontario, the principle of the Bill has been in
# operation for the past three years, and in the City of Moose Jaw,
-# Saskatchewan, for one year." Assume that the Thunder Bay region
-# observed DST starting 1910, and Moose Jaw starting 1912, as this
-# matches the Toronto Star report about Moose Jaw. For lack of better
-# info, assume the Thunder Bay region used Willett's proposal, namely
-# third Sunday in April at 02:00 to third Sunday in September at
-# 03:00; also assume that they continued until Canada instituted
-# uniform DST in 1918.
-Rule Thunder 1910 1917 - Apr Sun>=15 2:00s 1:00 D
-Rule Thunder 1910 1917 - Sep Sun>=15 2:00s 0 S

===

"Before 1909"

<http://cvsup.pt.freebsd.org/cgi-
bin/cvsweb/cvsweb.cgi/src/share/zoneinfo/northamerica?rev=1.25>

# From David Bryan via Tory Tronrud, Director/Curator,
# Thunder Bay Museum (2003-11-12):
# There is some suggestion, however, that, by-law or not, daylight
# savings time was being practiced in Fort William and Port Arthur
# before 1909.... [i]n 1910, the line between the Eastern and Central
# Time Zones was permanently moved about two hundred miles west to
# include the Thunder Bay area.... When Canada adopted daylight
# savings time in 1916, Fort William and Port Arthur, having done so
# already, did not change their clocks.... During the Second World
# War,... [t]he cities agreed to implement DST during the summer
# months for the remainder of the war years.

=====

"The waste of daylight" March 1914 pamflet, page 17:

<http://www.pettswoodvillage.co.uk/Daylight_Savings_William_Willett.pdf>

In the Cities of Fort William and Port Arthur, Ontario, the principle of
the bill has been in operation for the past three years, and in the City
of Moose Jaw, Saskatchewan, for one year.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 23 '06 #22
JRS: In article <Xn********************@194.109.133.242>, dated Wed, 23
Aug 2006 06:07:28 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>Dr John Stockton wrote on 23 aug 2006 in comp.lang.javascript:
>My temporary page $tab.htm

Not in here: <http://www.merlyn.demon.co.uk/programs/??
No, in the root directory; remove the last 9 characters above, getting
.... .uk/$tab.htm .

I did not want to post the location /en clair/, lest it be found by
search engines.

I have T8, the function for standard tabs, fairly well consolidated now;
still thinking about the properties of yours.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 23 '06 #23
Dr John Stockton wrote on 23 aug 2006 in comp.lang.javascript:
still thinking about the properties of yours.
#3:

<script type='text/javascript'>

function tabber(lines,tabarr){ // Evertjan 3
// lines needs one tabbed line or array of those lines
// tabbarray is default [8], or specified array, or number
// .. and recycles when too short
var result ='',t,tba,res,j,tabl,tabc;
lines = (!lines[0])?[lines]:lines;
tba = tabarr || [8]; // line now outside loop
if (!tba[0]) tba = [tba]; // ADDED: simple number allowed
for (var i=0;i<lines.length;i++) {
tabc = tabl = 0;
res = '';
t = lines[i].split('\t');
for (j=0;j<t.length;j++) {
res += t[j];
tabl += tba[tabc++] || tba[tabc=0];
while (res.length<tabl && j<t.length-1) // CHANGED line
res += '_'; // should be changed to space finally
};
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); // CHANGED: simple number allowed
document.write(r);

</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 24 '06 #24
JRS: In article <Xn********************@194.109.133.242>, dated Thu, 24
Aug 2006 07:43:14 remote, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.netposted :
>Dr John Stockton wrote on 23 aug 2006 in comp.lang.javascript:
>still thinking about the properties of yours.

#3:

There's still a fundamental difference, illustrated in "Different
Classes of Behaviour" on the page by

function XXX() { var J, A = [PT8, Tabber3], F
var S1 = "123\t123\txyz\t11\t12", S2 = "abcdefghij" + S1
for (J in A) { F = A[J]
document.writeln(FuncName(F), " :\n", F(S1), "\n", F(S2)) } }

the output of which is basically

PT8 :
123 456 xyz 11 12
abcdefghijk123 456 xyz 11 12

Tabber3 :
123_____456_____xyz_____11______12
abcdefghij123456kxyz____11______12

Mine always moves ahead to the next stop; yours, although more flexible,
is different with text too long for its field. (By using do...while to
insert spaces, you could ensure a minimum of one space between fields; I
think that really does need to be provided, though perhaps optional.)
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
Do not Mail News to me. Before a reply, quote with ">" or "" (SoRFC1036)
Aug 24 '06 #25
Dr John Stockton wrote on 25 aug 2006 in comp.lang.javascript:
Mine always moves ahead to the next stop; yours, although more flexible,
is different with text too long for its field. (By using do...while to
insert spaces, you could ensure a minimum of one space between fields; I
think that really does need to be provided, though perhaps optional.)
Certainly a good plan, that effect was accidenally lost half way the
development of tabber().

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

I am more interested to change a multiline tabbed text into a html <table>.
Such text is the result of copy/pasting a MS-word table to an editor. MS-
word cannot make decent html itself.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 25 '06 #26
JRS: In article <Tq**************@merlyn.demon.co.uk>, dated Mon, 21
Aug 2006 23:34:07 remote, seen in news:comp.lang.javascript, Dr John
Stockton <jr*@merlyn.demon.co.ukposted :
>
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.
If anyone has a browser that does not always display TAB in <preand
<textareaas 1..8 spaces to bring the length so far to a multiple of 8
and should happen to notice corresponding layout errors anywhere on my
site, I'd be grateful to hear which parts of the site are affected.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 3 '06 #27

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Amitabh Deepak | last post: by
1 post views Thread by Drew | last post: by
7 posts views Thread by Brett Edman | last post: by
reply views Thread by Chirag Shukla | last post: by
1 post views Thread by maflatoun | last post: by
1 post views Thread by maflatoun | last post: by
1 post views Thread by luke_airig | last post: by
3 posts views Thread by bernhard Hoyler | last post: by
27 posts views Thread by RobG | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.