Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Get the time zone and daylight saving time support for any US ZIP code

License

NotificationsYou must be signed in to change notification settings

infused/ziptz

Repository files navigation

VersionBuild StatusTotal DownloadsLicense

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

ZIP codes are up to date as ofMay 2024.

Compatibility

Ziptz is tested to work with the following versions of Ruby:

  • Ruby 3.1.x, 3.2.x, 3.3.x

Installation

Add the gem to your Gemfile:

gem 'ziptz'

Data File Requirement

Starting with version 6.0.0, you'll need to supply your own time zone SQLite database file. You can subscribe to the required dataset here:ZIP Code Time Zones Dataset

Usage

First, initialize Ziptz with the path to your time zone database file:

z = Ziptz.new('/path/to/your/tz.db')# or using keyword argumentz = Ziptz.new(db: '/path/to/your/tz.db')

Get the time zone name for any ZIP code:

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

Get the time zone offset for any ZIP code:

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

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/Chuuk') #=> ["96942", "96943"]

Supported Time Zones

  • America/Adak
  • America/Anchorage
  • America/Boise
  • America/Chicago
  • America/Denver
  • America/Detroit
  • America/Indiana/Indianapolis
  • America/Indiana/Knox
  • America/Indiana/Marengo
  • America/Indiana/Petersburg
  • America/Indiana/Tell_City
  • America/Indiana/Vevay
  • America/Indiana/Vincennes
  • America/Indiana/Winamac
  • America/Juneau
  • America/Kentucky/Louisville
  • America/Kentucky/Monticello
  • America/Los_Angeles
  • America/Menominee
  • America/Metlakatla
  • America/New_York
  • America/Nome
  • America/North_Dakota/Beulah
  • America/North_Dakota/Center
  • America/North_Dakota/New_Salem
  • America/Phoenix
  • America/Puerto_Rico
  • America/Sitka
  • America/St_Thomas
  • America/Yakutat
  • Pacific/Chuuk
  • Pacific/Guam
  • Pacific/Honolulu
  • Pacific/Kosrae
  • Pacific/Kwajalein
  • Pacific/Majuro
  • Pacific/Pago_Pago
  • Pacific/Palau
  • Pacific/Pohnpei
  • Pacific/Saipan
  • Pacific/Wake

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

Prefer raw data?

If you would prefer raw data instead of a gem, see myZIP Code Time Zones product on AWS Data Exchange to subscribe.

Version 3 breaking changes

  • APO, DPO, and FPO zip codes are no longer included, because they are non-geographic.
  • Time zone offsets are now specified in seconds instead of hours.
  • Time zone are now more granular. The full list of time zones is:
    • America/Adak
    • America/Anchorage
    • America/Boise
    • America/Chicago
    • America/Denver
    • America/Detroit
    • America/Indiana/Indianapolis
    • America/Indiana/Knox
    • America/Indiana/Marengo
    • America/Indiana/Petersburg
    • America/Indiana/Tell_City
    • America/Indiana/Vevay
    • America/Indiana/Vincennes
    • America/Indiana/Winamac
    • America/Juneau
    • America/Kentucky/Louisville
    • America/Kentucky/Monticello
    • America/Los_Angeles
    • America/Menominee
    • America/Metlakatla
    • America/New_York
    • America/Nome
    • America/North_Dakota/Beulah
    • America/North_Dakota/Center
    • America/North_Dakota/New_Salem
    • America/Phoenix
    • America/Puerto_Rico
    • America/Sitka
    • America/St_Thomas
    • America/Yakutat
    • Pacific/Chuuk
    • Pacific/Guam
    • Pacific/Honolulu
    • Pacific/Kosrae
    • Pacific/Kwajalein
    • Pacific/Majuro
    • Pacific/Pago_Pago
    • Pacific/Palau
    • Pacific/Pohnpei
    • Pacific/Saipan
    • Pacific/Wake

Version 2 breaking changes

Time zone names now reflect standard tz-database names.

V1 NameV2 Name
AtlanticAmerica/Puerto_Rico
EasternAmerica/New_York
CentralAmerica/Chicago
MountainAmerica/Denver
PacificAmerica/Los_Angeles
Hawaii-Aleutian IslandsPacific/Honolulu or America/Adak
American SamoaPacific/Pago_Pago
Marshall IslandsPacific/Majuro
GuamPacific/Guam
PalauPacific/Palau
MicronesiaPacific/Pohnpei

License

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

Permission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentationfiles (the "Software"), to deal in the Software withoutrestriction, including without limitation the rights to use,copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the followingconditions:

The above copyright notice and this permission notice shall beincluded 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 WARRANTIESOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.

About

Get the time zone and daylight saving time support for any US ZIP code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp