Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
lib
test
CHANGES
LICENSE
README
Rakefile

README

= TZInfo -- Daylight-savings aware timezone support for Ruby

TZInfo[http://tzinfo.rubyforge.org] uses the tz database 
(http://www.twinsun.com/tz/tz-link.htm) to provide
daylight-savings aware transformations between times in different timezones.
This is the same database as used for zoneinfo on Unix machines.

The tz database has been imported (using TZDataParser) and turned into a set of
Ruby classes (which are packaged with this release).


== Example usage

To convert a time in UTC, to a local time in the America/New_York timezone, you
can do the following:

  require_gem 'tzinfo'
  include TZInfo
  
  tz = Timezone.get('America/New_York')
  local = tz.utc_to_local(DateTime.new(2005,8,29,15,35,0))
  
To convert from a local time to UTC, the local_to_utc method can be used:

  utc = tz.local_to_utc(local)
  
To get information about the rules in force at a particular UTC or local time,
the Timezone.period_for_utc and Timezone.period_for_local methods can be used.
Both of these methods return TimezonePeriod objects. The following gets the 
identifier for the period (in this case EDT).

  period = tz.period_for_utc(DateTime.new(2005,8,29,15,35,0))
  id = period.zone_identifier
  
In all the above examples, instances of Time can be used instead of DateTime.
Timezone.utc_to_local and Timezone.local_to_utc both return the type they are 
passed.

You can get the current local time in a Timezone with the Timezone.now method:

  now = tz.now
  
You can also access Timezones by Country (ISO 3166 country code). The following 
gets all the Timezone identifiers for the US:

  us = Country.get('US')
  timezones = us.zone_identifiers
  
The above covers the most common uses of Timezone and Country. For more detail,
see the API documentation for the individual classes.


== Download

The latest version of TZInfo can be found at

* http://rubyforge.org/frs/?group_id=894

API documentation can be found at 

* http://tzinfo.rubyforge.org/doc/


== Installation

The preferred method of installing TZInfo is through the GEM file (RubyGems[http://docs.rubygems.org/] required):

  % gem install tzinfo-x.y.z.gem
  
or to automatically download and install:

  % gem install tzinfo --remote
  

== License

TZInfo is released under the MIT[http://opensource.org/licenses/mit-license.html] license.


== Support

Please post to the TZInfo Users mailing list (http://rubyforge.org/mailman/listinfo/tzinfo-users)
if you require assistance or have any suggestions.

Alternatively, you can contact the author Philip Ross directly at phil.ross@gmail.com.
Something went wrong with that request. Please try again.