arshaw / xdate

A Modern JavaScript Date Library

Home Page:http://arshaw.com/xdate/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Full timezone support

samlown opened this issue · comments

I'm a big fan of XDate, its saved me a load of time handling dates gracefully in several projects, both in client and node.js.

However, I've run into a bit of a road-block with timezones. Turns out support for them in Javascript/Browsers is practically non-existant unless you want to use the OS's current timezone configured by the user.

I've been experimenting with timezone-JS (https://github.com/mde/timezone-js) which works pretty well at handling the zones, loading the definitions from the server etc., but the API for toString formatting or date arithmetic is no where near as good as it is in XDate, especially with regard to i18n.

Are there any plans to add timezone support, perhaps by extracting the good bits from timezone-js into XDate? My first impression is that the UTCmode argument could be replaced with the timezone and still provide backwards compatibility.

Over the weekend I decided to put together a quick hack of timezone-js with XDate formatting and renamed it "TZDate" so that it acts more or less as a drop-in replacement: https://github.com/samlown/tzdate

If I get chance I'd like to copy over more of the XDate arithmetic code, but at the moment it works great for localised toString calls with proper timezones.

i know this is from a while ago but... i think this is really cool. I originally looked at timezone-js and wanted to take the same approach w/ parsing the Olson files and whatnot, but decided against it b/c it was too hard. Nice work! I'm closing this issue though, b/c there is nothing actionable for the XDate project, but thanks for letting us know about it.