Sha256: d4c728b5dd881031ae0d8b471b96e26c106561e93f9f2e3e6a97e68d5238fd02

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

= zip_to_timezone

{<img src="https://travis-ci.com/rgarver/zip_to_timezone.svg?branch=master" alt="Build Status" />}[https://travis-ci.com/rgarver/zip_to_timezone]

This gem is designed to map US postal codes to the timezone.  The timezone
strings are based on ActiveSupport::TimeZone settings that include basic DST
information.  If used with Rails these timezones will handle DST changes on
their own.

== Installation

 gem install zip_to_timezone

If you are using bundler you can add a line to your <tt>Gemfile</tt>:

 gem "zip_to_timezone"

== Usage

This is super simple to use:

 ZipToTimezone.get_timezone_for('91304') # => "Pacific Time (US & Canada)"

== How it works

This uses Trei longest prefix matching to speed up the searching.  This means
that all zip codes that start with 90 will be in California and therefore are in
Pacific Time.  If I need to match on full zip codes in some states to
differentiate timezones I can do that (eg: Kansas or Indiana) by just adding
more specific entires.

== Note on accuracy

This gem combines two things that kind of suck to make them suck less.  To do
this though I had to make a lot of guesses.  Please let me know if there are bad
mappings so I can fix them.  My data is imperfect and in some places outright
wrong.  The goal of the project was to handle the 95% case and hopefully grow it
to be more accurate over time.

== References

* http://www.worldtimezone.com/time-usa12.php
* http://en.wikipedia.org/wiki/ZIP_code_prefixes

== Note on Patches/Pull Requests

* Fork the project.  Make your feature addition or bug fix.  Add tests for it.
* This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a
commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2009 Ryan Garver. See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zip_to_timezone-0.2.0 README.rdoc