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: Jim Davis <newsmonkey@vboston.com>
Date: Wed Aug 31 2005 - 03:47:48 CEST

"Dr John Stockton" <jrs@merlyn.demon.co.uk> wrote in message
news:+nnDl3BhTOFDFwaN@merlyn.demon.co.uk...
> 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.

New topic... new thread. Seems simple to me.

While this topic may be related to another it has both greater specificity
and broader appeal (for adjusting timezones is only one small part of
converting iso8601 dates and applicable to much more than iso8601 dates).
Any answers may inform the other but are not part of the same discussion.

Honestly it seems like you're being rather pendantic about this (or in
general I don't you so perhaps it's that). For archiving purposes
specific,searchable subjects are generally respected on Usenet.

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

In other words actually obtaining the offset is not the problem (I do not
need help in extracting it). My question concerned the conversion of one
timezone to another.

> 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(,,,,,,)) .

Well... only if I want UTC time. ;^)

My spec is clear that, if timezone information provided, it should be used
to convert the time to local time.

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

Perhaps I'm missing it. I see nothing in the FAQ that concerns this. A
rather extensive search didn't produce the answer I needed.

I'm neither too proud or too stupid to existing code when I can find it and
when it's appropriately licensed.

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

That does not convert a date... it provides the UTC date.

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

Not an issue for puposes of discussion.

I thank you for your effort, however. I've since solved the problem and
will shortly post a resolution.

It really should have have clearer, but I was having a mental block on
this... once I got a nap in it became much clearer.

Jim Davis
Received on Tue Oct 18 03:14:55 2005