Class: Ziptz

Inherits:
Object
  • Object
show all
Defined in:
lib/ziptz.rb

Constant Summary collapse

VERSION =
'2.1.10'.freeze
TZ_INFO =
{
  '0' => {name: 'APO/FPO (time zone unknown)', offset: 0},
  '4' => {name: 'America/Puerto_Rico', offset: -4},
  '5' => {name: 'America/New_York', offset: -5},
  '6' => {name: 'America/Chicago', offset: -6},
  '7' => {name: 'America/Denver', offset: -7},
  '8' => {name: 'America/Los_Angeles', offset: -8},
  '9' => {name: 'America/Anchorage', offset: -9},
  '10' => {name: 'Pacific/Honolulu', offset: -10},
  '11' => {name: 'Pacific/Pago_Pago', offset: -11},
  '13' => {name: 'Pacific/Majuro', offset: 12},
  '14' => {name: 'Pacific/Guam', offset: 10},
  '15' => {name: 'Pacific/Palau', offset: 9},
  '16' => {name: 'Pacific/Pohnpei', offset: 11},
  'AZ' => {name: 'America/Phoenix', offset: -7},
  'AD' => {name: 'America/Adak', offset: -10}
}.freeze

Instance Method Summary collapse

Instance Method Details

#inspectObject


41
42
43
# File 'lib/ziptz.rb', line 41

def inspect
  "#<#{self.class}:#{object_id}>"
end

#time_zone_name(zip) ⇒ Object


24
25
26
# File 'lib/ziptz.rb', line 24

def time_zone_name(zip)
  get_time_zone(zip)
end

#time_zone_offset(zip) ⇒ Object


28
29
30
31
# File 'lib/ziptz.rb', line 28

def time_zone_offset(zip)
  tz = time_zone_info(zip)
  tz && tz[:offset]
end

#time_zone_uses_dst?(zip) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
# File 'lib/ziptz.rb', line 33

def time_zone_uses_dst?(zip)
  dst[zip.to_s.slice(0, 5)]
end

#zips(tz_name) ⇒ Object


37
38
39
# File 'lib/ziptz.rb', line 37

def zips(tz_name)
  zips_by_code(tz_name)
end