Re: Adjusting for Timezone
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Adjusting for Timezone

From: Dr John Stockton <jrs@merlyn.demon.co.uk>
Date: Wed Aug 31 2005 - 00:59:45 CEST

JRS: In article <df1vn6026dh@news2.newsguy.com>, dated Tue, 30 Aug 2005
11:58:36, seen in news:comp.lang.javascript, Jim Davis
<newsmonkey@vboston.com> posted :
>I'm (still) working on an ISO 8601 date parser.

Please do not start a new thread to continue an existing discussion. As
a thread develops, it is taken for granted that some progress may be
made.

>The datetime may come with an optional timezone offset (from GMT) as here
>(the offset is +1 hour from GMT):
>
>1997-07-16T19:20:30+01:00
>
>So... that's the current time there... but my spec is that timezone
>information, if present, should be used to convert the given time to local
>time. For me, for example, this would be -5:00 from GMT.
>
>I've already split the Timezone information: I've got indiviual access to
>the sign (plus or minus), the hour offset and the minute offset.

There are 60 minutes in each hour; I see no other possible difficulty.
In fact, you do not even need to know that. Perhaps you should explain
your problem more clearly.

Remember that you should not use new Date(Y, M, D, h, m, s, ms) as
that muddles the situation with your local zone. Use new
Date(Date.UTC(,,,,,,)) .

Read the FAQ; see below. Use extant resources before reinventing
wheels.

Consider
        new Date(Date.UTC(Y, M, D, h+oh, m+om, s, c))
where oh, om are the offsets and maybe + should be - ; that's not
explicit in the cited resource but should be obvious after reading it.

Consider whether the input should be validated; perhaps not, if your
data source is reliable.
 

-- 
 © 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.htm> jscr maths, dates, sources.
 <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Received on Tue Oct 18 03:14:47 2005