sorry for this trivial question about dates

D

David Lindsay

I want to put date and time on my web page, and to be sure it tracks the
BST/ GMT changes.
Can anyone help me, I have gone back in my historic file for quite a
while and not found anything.
Sorry about the newbie trivial question
 
E

Evertjan.

David Lindsay wrote on 17 sep 2003 in comp.lang.javascript:
I want to put date and time on my web page, and to be sure it tracks the
BST/ GMT changes.
Can anyone help me, I have gone back in my historic file for quite a
while and not found anything.
Sorry about the newbie trivial question

What do you mean by BST/ GMT changes ?

Time changes all the time. ;-)

Do you want the time in GMT/UTC or in west european time?

Do you want client time or server time ?
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
I want to put date and time on my web page, and to be sure it tracks the
BST/ GMT changes.
Can anyone help me, I have gone back in my historic file for quite a
while and not found anything.
Sorry about the newbie trivial question

Try reading the newsgroup FAQ on the subject of dates and times.

I assume that you mean the current date and time.

If you want to be SURE of always being correct, you must yourself
include the current EU rules for the change, and update whenever
necessary (unlikely). At least one delivered version of Windows has the
rules for the UK wrong.

Putting the current local date & time is a pointless exercise; most OSs
already show it, most users know the date and can see a proper clock or
a watch.

There is a use for showing the current British time to foreigners; for
example to help Radio 2 listeners sited across the Channel.

For use in the EU, you only need to apply the correct fixed offset to
their local time; but for that you need their location, which can be
adequately deduced from new Date(0).getTimezoneOffset().

Otherwise, you need to implement the UK Rules, as in js-date5.htm#UKnow
function BritNow (uses EUch). Note that the UTC of the resulting Object
must be displayed; UTCDstr is in include3.htm, visible in js-nclds.htm

If you are only interested in readers whose computer uses UK time, and
can disregard possible OS errors, display the date object directly, but
do not use toLocaleString (it is wrong in my browser). Best to supply a
display routine such as ISOlocalDTstr (/loc cit/).

You should, of course, point out the dependence on the correctness of
the viewing computer's time adjustment.
 
D

David Lindsay

Evertjan. said:
David Lindsay wrote on 17 sep 2003 in comp.lang.javascript:


What do you mean by BST/ GMT changes ?
we change from GMT to British summer Time and back again every year
Do you want the time in GMT/UTC or in west european time?

The actual time in the United Kingdom, as on the server.
Do you want client time or server time ?
TIA
 
E

Evertjan.

David Lindsay wrote on 19 sep 2003 in comp.lang.javascript:
we change from GMT to British summer Time and back again every year
The actual time in the United Kingdom, as on the server.

Wich is Western European time.

If we are talking client coding:
If the client machine is correctly configured and has the correct time and is in the UK,
you can just take the javascript time functions, they are correct.

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

If we are talking server coding and the server has the correct time and is in the UK the
same applies.

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

if the server is somewhere else, say in Toronto, then you are in trouble. The swich
times are hours and sometimes a also week apart.

Serverside ASP javascript can deduct the actual UTC time.
For correction to Western European Summertime you can add one hour to UTC, but the
switch moment has to be hardcoded in your code, I presume.

Not tested, but try it out:

<script language=javascript runat=server>

summertimestart03 = Date.UTC(2003,3-1,30,1);
summertimeend03 = Date.UTC(2003,10-1,26,1);
// see <http://www.npl.co.uk/time/time_summer.html>

d = new Date();
if((d>summertimestart03)&&(d<summertimeend03))d+=60*60*1000;
if((d>summertimestart04)&&(d<summertimeend04))d+=60*60*1000;
if((d>summertimestart05)&&(d<summertimeend05))d+=60*60*1000;
c = ":";
s = d.getUTCHours() + c;
s += d.getUTCMinutes() + c;
s += d.getUTCSeconds() + c;
s += d.getUTCMilliseconds();

Response.write(s);

</script>

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

see for more help:

<http://www.merlyn.demon.co.uk/uksumtim.htm>
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
David Lindsay wrote on 19 sep 2003 in comp.lang.javascript:

UK civil time is identical to Dutch, except that good Dutch clocks are
*always* an hour ahead of ours.
Wich is Western European time.

You might call it that; we do not! What do you call the Dutch and
Graeco-Finnish time zones in Europe?
if the server is somewhere else, say in Toronto, then you are in trouble. The
swich
times are hours and sometimes a also week apart.

No problem. It's all done somewhere on my site; if Toronto time is not
New York time (the map in my diary is *small*, just change 5 to 6)
Serverside ASP javascript can deduct the actual UTC time.
For correction to Western European Summertime you can add one hour to UTC, but
the
switch moment has to be hardcoded in your code, I presume.

Indeed not. In js-date5.htm (M=3 or M=10) :

function EUch(Y, M) { // return ms of Spring/Autumn EU clock change
var J = Date.UTC(Y, M-1, 31) // last of month is 31st, get UTC
return J - 864e5*((4+J/864e5)%7) + 36e5 /* Sun, 0100 GMT, ms */ }

Valid for all years and all of the EU under present rules.

I've not consolidated the NA code to that extent, but it includes

var DSTon = (new Date(Date.UTC(Yr, 03, 07, 2-TZ))).toSunday()
var DSTof = (new Date(Date.UTC(Yr, 09, 31, 1-TZ))).toSunday()

with
Date.prototype.toSunday = new Function( // back by 0-6 days
'return new Date(this.setDate(this.getDate()-this.getDay()))')

For NY (& To?), TZ=-5.

<URL:http://www.merlyn.demon.co.uk/js-date5.htm#DDTA> does it for
anywhere, al long as a suitable TZ string can be provided. Tel Aviv
might be difficult.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
The actual time in the United Kingdom, as on the server.

AIUI, servers generally run on GMT, even in outlandish places like other
countries, and even in the Summer. It is not a server's business to
care where its clients are or think they are. AIUI, there is, for
example, a piece of the British Mainland that operates on Paris time.

It seems clear that you want to display, to a correctly-set user
anywhere in the world, the time we use here - UK Civil Time.

Give or take a quibble about whether UK Civil Time is or should be UTC
or GMT. I think the best UK clocks show UTC, but legally Summer Time
starts/stops by GMT. It may have changed.


function BritNow(Now) { // gives UTC with UK time numbers
var yr = Now.getUTCFullYear()
var EUSTon = EUch(yr, 03), EUSTof = EUch(yr, 10)
// abroad: add winter TZ offset; update change rules if not EU
var ms = Now.getTime() // GMT
if ((ms>=EUSTon) && (EUSTof>ms)) ms += 3600000 // +1h
return new Date(ms) }

function TryBritNow() { document.writeln(
'<table summary="British Date"',
' bgcolor=#FFA500 align=center cellpadding=10>',
'<tr><td>Page shown at ',
BritNow(new Date()).UTCDstr(), ' British civil time,',
' by your clock.<\/td><\/tr><\/table>') }

which drives <URL:http://www.merlyn.demon.co.uk/js-date5.htm#UKNow>.
 
E

Evertjan.

Dr John Stockton wrote on 19 sep 2003 in comp.lang.javascript:
UK civil time is identical to Dutch, except that good Dutch clocks are
*always* an hour ahead of ours.


You might call it that; we do not! What do you call the Dutch and
Graeco-Finnish time zones in Europe?

There is no Dutch time zone nowadays!

Europe ["The union as we know it"] has three time zones:

Western European Time
Central European Time
Eastern European Time

If you want to call your time "British standard time" or "London time" ot
"Travalgar square time", so be it, but those are only local names of the
same, these are leftover names from the time when local time was
different in each town or count(r)y, and railway time was another time
again.

Any question about time zone manipulation code on an internationally used
NG should address the whole of the time zone and not just such a local
name.

I, as an European, am proud the Europen times switches to and from
summertime (US: daylight saving time) at the same absolute time, 01:00
UTC, and not like the North American system where the switch ripples
through the continent, and interstate travel on those nights sould be an
exact local time loving exentric's nightmare. In eastern British Columbia
the time zone border runs through the province with roadside notices
warning you on an very irregular basis. In other places I suppose it is
the same.

The nice thing about serverside javascript is that you can get to UTC
immediately, or detect the servers time zone difference.

Serverside vbscript does not have these options, so if you have a server
in Toronto and want to go to UTC or one of the three European times, you
would have to incorporate the Toronto local (EST?) switch times.
No problem. It's all done somewhere on my site; if Toronto time is
not New York time (the map in my diary is *small*, just change 5 to 6)
[ .... etc ... ]

That is why I put a link to your site in my posting, John, your solutions
are by far the most extensive and well tested.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
I, as an European, am proud the Europen times switches to and from
summertime (US: daylight saving time) at the same absolute time, 01:00
UTC, and not like the North American system where the switch ripples
through the continent, and interstate travel on those nights sould be an
exact local time loving exentric's nightmare. In eastern British Columbia
the time zone border runs through the province with roadside notices
warning you on an very irregular basis. In other places I suppose it is
the same.

There may be problems when the EU eventually fills Europe; that needs
another two zones, and if the change remains at 1 am UTC it will in the
autumn be at 6 am local time by the Asian Border. And Central European
Time will no longer be in the middle; we shall be no better than those
who have the Mid-West well to the East of centre.

But you may not be quite right in saying that the whole EU changes
clocks simultaneously. Brussels has, I agree, said 01:00 UTC; but I
think that the corresponding UK document may put the changes at 01:00
GMT - which can differ by up to 0.9 seconds.

Does anyone know what the 10 (?) about-to-join countries do about Summer
Time?

-

Site editors : mtr -x+ -o/~ *.htm - "this\s+that\s+tother" lists all
files not containing that phrase, whatever the whitespace
 
E

Evertjan.

Dr John Stockton wrote on 20 sep 2003 in comp.lang.javascript:
But you may not be quite right in saying that the whole EU changes
clocks simultaneously. Brussels has, I agree, said 01:00 UTC; but I
think that the corresponding UK document may put the changes at 01:00
GMT - which can differ by up to 0.9 seconds.

I certainly doubt that. The UK specs only differ from the rest if it is in
the political interest of the uk government to take the trouble, such as in
the case of the euro, and 0.9 seconds does not win votes in any local
election.

Or the legislators did not know of any difference between GMT and UTC.

40000000 meter x cos 52deg = 24626459 meters
1 day = 86400 seconds
1 second = 285 meter
0.9 second = 256 meter

So the meridian at Greenwich moves a maximum of 256 meters in the maimum
time difference between UTC and GMT. That cannot be acepted ! The Eurostar
would make a big jump between France and the UK, endangering the many
pedestrian illegal immigrants. Talking of tunnel vision.
 
E

Evertjan.

D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
Dr John Stockton wrote on 20 sep 2003 in comp.lang.javascript:


UK law 1997:
<http://webexhibits.org/daylightsaving/uk.html>

EU law 2000:
<http://webexhibits.org/daylightsaving/eu.html>

They are, I believe, American; they are certainly not authoritative; but
they may be right.

<http://www.dti.gov.uk/er/sumtimetb.htm>, updated 20 March 2003, uses
GMT. It links to <http://europa.eu.int/smartapi/cgi/sga_doc?smartapi!ce
lexapi!prod!CELEXnumdoc&lg=EN&numdoc=32000L0084&model=guichett> of 19
January 2001 which uses GMT. Those are authoritative.

But <http://www.merlyn.demon.co.uk/uksumtim.htm> has noted that
"Statements about the EU rules are derived from the English version
(which uses GMT; others do not)."
 
E

Evertjan.

Dr John Stockton wrote on 21 sep 2003 in comp.lang.javascript:
They are, I believe, American; they are certainly not authoritative;
but they may be right.

<http://www.dti.gov.uk/er/sumtimetb.htm>, updated 20 March 2003, uses
GMT. It links to
<http://europa.eu.int/smartapi/cgi/sga_doc?smartapi!ce
lexapi!prod!CELEXnumdoc&lg=EN&numdoc=32000L0084&model=guichett> of 19
January 2001 which uses GMT. Those are authoritative.

But <http://www.merlyn.demon.co.uk/uksumtim.htm> has noted that
"Statements about the EU rules are derived from the English version
(which uses GMT; others do not)."

Such laws or regulations should refer to UTC, IMHO.

On the other hand, is the exactness of legal local time within one
second that important?

Any serious scientific time measurement on that level of tolerance
should be in UTC.

Imagine a police officer saying: "You are not using your headlights at
night and it night since is 0.9 seconds". That would be zero-tolerance !
 

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
474,093
Messages
2,570,607
Members
47,226
Latest member
uatas12

Latest Threads

Top