iana_converter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d77ce3ca28a255c6e05a451ae04c2ca9cc062a3f
4
- data.tar.gz: 7afa69afded95fc7242afabe771bf579615d42d2
3
+ metadata.gz: 5376ee0e8bbfe2bca7871f563dfe5a1c543fc630
4
+ data.tar.gz: e60cabc7e0203d703c20aa153e0e8629fd415e8b
5
5
  SHA512:
6
- metadata.gz: 6c376eee7c9aca5db9151f4037a8e1ef848ceba994af536af4d8875a6aee716ca3e639c921406e9934200b899d4a8da95cdf35b24cd606582f3edb9e4819274e
7
- data.tar.gz: fef43c32adf1f85eb67ed24d9837bc383ffd59e0177bb56020bbf4a1377f95ebd2514fc12f1de06c14524b460f21a08f3e330f05ca05779751528ae1e2a274eb
6
+ metadata.gz: e906d458a9f1022beb70e3c3ba4d5fabf50eec7a81d27ac34df9579d1e949133d81a552a71a0e449bd798564127bb2660d3b0d5840075feb78a5005dfd216820
7
+ data.tar.gz: bdb7df93c5124d6c077b2e126ea1f9317f4a72f124f7c20e4238e7332f2762403a862ed79114fe17e270e4f1bee485693ae29ac1df9d3b3c7e293fd6e9e80a4a
@@ -3,7 +3,7 @@
3
3
 
4
4
  module IANA_Converter
5
5
 
6
- # The Complete IANA US Timezone list with mappings to the 'important' timezones that Rails recognizes
6
+ # The Complete IANA US Timezone list with mappings to Rails timezones.
7
7
  US_TIMEZONE_MAPPING = {
8
8
  'America/New_York' => 'America/New_York',
9
9
  'America/Detroit' => 'America/New_York',
@@ -33,15 +33,52 @@ module IANA_Converter
33
33
  'America/Yakutat' => 'America/Juneau',
34
34
  'America/Nome' => 'America/Juneau',
35
35
  'Pacific/Honolulu' => 'Pacific/Honolulu',
36
- 'America/Adak' => 'America/Adak'
36
+ 'America/Adak' => nil
37
+ }.freeze
38
+
39
+ # The complete IANA CA Timezone list with mappings to Rails timezones
40
+ CA_TIMEZONE_MAPPING = {
41
+ 'America/St_Johns' => 'America/St_Johns',
42
+ 'America/Halifax' => 'America/Halifax',
43
+ 'America/Glace_Bay' => 'America/Halifax',
44
+ 'America/Moncton' => 'America/Halifax',
45
+ 'America/Goose_Bay' => 'America/Halifax',
46
+ 'America/Blanc-Sablon' => nil,
47
+ 'America/Toronto' => 'America/New_York',
48
+ 'America/Nipigon' => 'America/New_York',
49
+ 'America/Thunder_Bay' => 'America/New_York',
50
+ 'America/Iqaluit' => 'America/New_York',
51
+ 'America/Pangnirtung' => 'America/New_York',
52
+ 'America/Atikokan' => nil,
53
+ 'America/Winnipeg' => 'America/Chicago',
54
+ 'America/Rainy_River' => 'America/Chicago',
55
+ 'America/Resolute' => 'America/Chicago',
56
+ 'America/Rankin_Inlet' => 'America/Chicago',
57
+ 'America/Regina' => 'America/Guatemala',
58
+ 'America/Swift_Current' => 'America/Guatemala',
59
+ 'America/Edmonton' => 'America/Denver',
60
+ 'America/Cambridge_Bay' => 'America/Denver',
61
+ 'America/Yellowknife' => 'America/Denver',
62
+ 'America/Inuvik' => 'America/Denver',
63
+ 'America/Creston' => 'America/Phoenix',
64
+ 'America/Dawson_Creek' => 'America/Phoenix',
65
+ 'America/Fort_Nelson' => 'America/Phoenix',
66
+ 'America/Vancouver' => 'America/Los_Angeles',
67
+ 'America/Whitehorse' => 'America/Los_Angeles',
68
+ 'America/Dawson' => 'America/Los_Angeles'
37
69
  }.freeze
38
70
 
39
- # Converts the object into textual markup given a specific format.
71
+ # A mapping to `nil` indicates that either:
72
+ # # I was unable to figure out which timezone's rules match the key timezone
73
+ # # Rails does not have a timezone whose rules match the key timezone.
74
+ MASTER_MAP = {}.merge!(US_TIMEZONE_MAPPING).merge!(CA_TIMEZONE_MAPPING)
75
+
76
+ # Finds which Timezone string Rails uses to reference an IANA/OLSON timezone.
40
77
  #
41
78
  # @param iana_timezone [String] the IANA/OLSON timezone you are trying to use, `'America/Boise'` as an example
42
79
  # @return [String] the rails timezone that encapsulates the timezone you converted.
43
80
  def rails_timezone_for(iana_timezone)
44
- US_TIMEZONE_MAPPING[iana_timezone]
81
+ MASTER_MAP[iana_timezone]
45
82
  end
46
83
 
47
84
  end
@@ -0,0 +1,30 @@
1
+ CA_TIMEZONE_MAPPING = {
2
+ 'America/St_Johns' => 'America/St_Johns',
3
+ 'America/Halifax' => 'America/Halifax',
4
+ 'America/Glace_Bay' => 'America/Halifax',
5
+ 'America/Moncton' => 'America/Halifax',
6
+ 'America/Goose_Bay' => 'America/Halifax',
7
+ 'America/Blanc-Sablon' => nil,
8
+ 'America/Toronto' => 'America/New_York',
9
+ 'America/Nipigon' => 'America/New_York',
10
+ 'America/Thunder_Bay' => 'America/New_York',
11
+ 'America/Iqaluit' => 'America/New_York',
12
+ 'America/Pangnirtung' => 'America/New_York',
13
+ 'America/Atikokan' => nil,
14
+ 'America/Winnipeg' => 'America/Chicago',
15
+ 'America/Rainy_River' => 'America/Chicago',
16
+ 'America/Resolute' => 'America/Chicago',
17
+ 'America/Rankin_Inlet' => 'America/Chicago',
18
+ 'America/Regina' => 'America/Guatemala'
19
+ 'America/Swift_Current' => 'America/Guatemala'
20
+ 'America/Edmonton' => 'America/Denver',
21
+ 'America/Cambridge_Bay' => 'America/Denver',
22
+ 'America/Yellowknife' => 'America/Denver',
23
+ 'America/Inuvik' => 'America/Denver',
24
+ 'America/Creston' => 'America/Phoenix',
25
+ 'America/Dawson_Creek' => 'America/Phoenix',
26
+ 'America/Fort_Nelson' => 'America/Phoenix',
27
+ 'America/Vancouver' => 'America/Los_Angeles',
28
+ 'America/Whitehorse' => 'America/Los_Angeles',
29
+ 'America/Dawson' => 'America/Los_Angeles'
30
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iana_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Karnes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-14 00:00:00.000000000 Z
11
+ date: 2018-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  This gem is designed to provide a modular, complete, open-source, crowd-sourced mapping of the 650+ IANA/OLSON timezones of the world into Rails' 146 'important' timezones.
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - lib/iana_converter.rb
23
+ - lib/mappings/ca_mapping.rb
23
24
  - lib/mappings/us_mapping.rb
24
25
  homepage: http://rubygems.org/gems/iana_converter
25
26
  licenses: