Ruby Time class is the one of the most disappointment parts of the ruby standard library.
- It can’t handle time zones by design (although some methods accept time zone as a parameter) and this can’t be changed by third party libraries (except via creating a new class (as Rails does)).
- It has pure ruby implementation of time parsing method, which is awfully slow.
The initial idea of this project was to reimplement ruby Time class with first class time zones support. But, after a couple of discussion, I realized that, dispite there are some cases when it usefull, storing timezone with time generaly brings more drawbacks than advantages. So currently library just fixes couple of ruby Time
methods by adding fast cross platform implementation (Time.local
, Time.utc
, Time.strptime
, generaly 10-100 times faster then alternatives).
How can I use system tz database ?
At the moment library uses global variable $__tz_directory
as a tz database location directory. It’s configured automaticaly to use bundled tz database in time of library loading.
Many OS (but not all) contain own tz database, so if you want to use system (or any other) tz database, you should set $__tz_directory
before require 'time2'
statement.
Code tested on Debian Lenny with GCC 4.3.3, Mac OS X with GCC 4.0.1 and Windows with VC 9
- tz database for the excellent time zones database and initial version of time functions
- postgresql for initial multitimezone code modification
- free BSD project for initial strptime implementation
Same terms as Ruby unless otherwise specified in the file.