XDate: JavaScript dates with real timezone support

2006-11-04 04:13:00

JavaScript, as a client-side language, has somewhere between slim and nothing when it comes to timezone support -- it's pretty much limited to getting the offset from GMT for whatever timezone the local machine happens to be set to.

Thinking about ways to fill in this gap, I've been spending some time the past couple of weekends working on a real timezone solution for working with dates in JavaScript.

I started with some code to parse the Olson timezone database (AKA the tz database, the zoneinfo database), and then used that to start implementing a complete drop-in replacement for JavaScript Date with full timezone support.

What I ended up with was something I'm calling XDate/XDateTime (because it's 'extended' functionality beyond the native JS Date -- well, and also because the letter 'X' is just cool). It's API-compatible with the JavaScript Date (all the same setters and getters, the constructor works pretty much the same way), but has full Olson-based timezone support.

I've got an XDate demo page set up with some documentation, and also the actual code and the North American timezones ('America/Los_Angeles,' 'America/Chicago,' etc.) loaded up for anyone who's interested in having a look at it. It's also got links to the source code for the XDate/XDateTime objects, as well as the Olson timezone parsing code.


This is the blog for Matthew Eernisse. I currently work at Yammer as a developer, working mostly with JavaScript. All opinions expressed here are my own, not my employer's.


Previous posts

All previous posts ยป

This blog is a GeddyJS application.