Skip to content
Get the time zone for any US ZIP code
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data July 2019 zip code updates Jul 1, 2019
lib
spec run specs in random order Jun 7, 2019
.gitignore check in rubocop config Jun 7, 2019
.rubocop.yml disable Gemspec/RequiredRubyVersion cop Jun 7, 2019
.ruby-gemset check in .ruby-version Jan 4, 2019
.ruby-version switch to ruby-2.6.2 for development Apr 18, 2019
.travis.yml January 2019 zip code update Feb 2, 2019
Gemfile make rake console work again Jun 2, 2019
Gemfile.travis
Guardfile set guard cmd Nov 2, 2016
LICENSE update copyright for 2019 Jan 4, 2019
README.md July 2019 zip code updates Jul 1, 2019
Rakefile remove unnecessary to_s Jun 7, 2019
ziptz.gemspec update summary May 3, 2018

README.md

Ziptz

Version Build Status Total Downloads License

Get time zone and daylight saving time for any US ZIP code.

ZIP codes are up to date as of July 2019.

Installation

Add the gem to your Gemfile:

gem 'ziptz'

Usage

Get the time zone name for any ZIP code:

z = Ziptz.new
z.time_zone_name('97213') #=> "America/Los_Angeles"

Get the time zone offset for any ZIP code:

z.time_zone_offset('97213') #=> -8

Note that offsets do not include daylight saving time.

Determine if the ZIP code uses Daylight Saving Time:

z.time_zone_uses_dst?('97213') #=> true

Get all the zip codes in a time zone:

z.zips('Pacific/Pago_Pago') #=> ["96799", "96941", "96942", "96943", "96944"]

Supported Time Zones

  • "America/Puerto_Rico" UTC -04:00
  • "America/New_York" UTC -05:00
  • "America/Chicago" UTC -06:00
  • "America/Denver" UTC -07:00
  • "America/Los_Angeles" UTC -08:00
  • "America/Anchorage" UTC -09:00
  • "Pacific/Honolulu" UTC -10:00
  • "Pacific/Pago_Pago" UTC -11:00
  • "Pacific/Majuro" UTC +12:00
  • "Pacific/Guam" UTC +10:00
  • "Pacific/Palau" UTC +09:00
  • "Pacific/Pohnpei" UTC +11:00

Note that APO/FPO zip codes will not return a known time zone offset.

Version 2 breaking changes

Time zone names now reflect standard tz-database names.

V1 Name V2 Name
Atlantic America/Puerto_Rico
Eastern America/New_York
Central America/Chicago
Mountain America/Denver
Pacific America/Los_Angeles
Hawaii-Aleutian Islands Pacific/Honolulu
American Samoa Pacific/Pago_Pago
Marshall Islands Pacific/Majuro
Guam Pacific/Guam
Palau Pacific/Palau
Micronesia Pacific/Pohnpei

License

Copyright (c) 2015-2019 Keith Morrison <keithm@infused.org>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.