arshaw / xdate

A Modern JavaScript Date Library
http://arshaw.com/xdate/
GNU General Public License v2.0
681 stars 81 forks source link

Full timezone support #14

Closed samlown closed 11 years ago

samlown commented 12 years ago

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.

samlown commented 12 years ago

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.

arshaw commented 11 years ago

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.