Re: [LIP] Time display in my choice of timezone using javascript
"Binand Sethumadhavan" <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
On 14/06/06, Babu Kalakrishnan <[email protected]> wrote: > Don't think there's anything built into Javascript to handle > timezones other than the local one. > > http://www.merlyn.demon.co.uk/js-date5.htm Yeah, I did google and reach that page. So here is what I am doing. Create an instance of Date(). Use getUTC*() methods to get year, month etc. in UTC. Hardcode my chosen zone's DST rules to convert the UTC timestamp to said zone. The screw-up is that US/Eastern had one rule last year (2005), another this year (2006), and yet another one next year (2007). Adjust the hour/date/month/year for the difference (4h/5h). Handle month changes, year changes, and even leap years :( Look at cat /dev/urandom for slightly more readable code. Binand