iana_converter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d77ce3ca28a255c6e05a451ae04c2ca9cc062a3f
4
+ data.tar.gz: 7afa69afded95fc7242afabe771bf579615d42d2
5
+ SHA512:
6
+ metadata.gz: 6c376eee7c9aca5db9151f4037a8e1ef848ceba994af536af4d8875a6aee716ca3e639c921406e9934200b899d4a8da95cdf35b24cd606582f3edb9e4819274e
7
+ data.tar.gz: fef43c32adf1f85eb67ed24d9837bc383ffd59e0177bb56020bbf4a1377f95ebd2514fc12f1de06c14524b460f21a08f3e330f05ca05779751528ae1e2a274eb
@@ -0,0 +1,47 @@
1
+ # Better IANA Timezone Mapping
2
+ # @author Justin Karnes <justin@perfectcube.co>
3
+
4
+ module IANA_Converter
5
+
6
+ # The Complete IANA US Timezone list with mappings to the 'important' timezones that Rails recognizes
7
+ US_TIMEZONE_MAPPING = {
8
+ 'America/New_York' => 'America/New_York',
9
+ 'America/Detroit' => 'America/New_York',
10
+ 'America/Kentucky/Louisville' => 'America/New_York',
11
+ 'America/Kentucky/Monticello' => 'America/New_York',
12
+ 'America/Indiana/Indianapolis' => 'America/New_York',
13
+ 'America/Indiana/Vincennes' => 'America/New_York',
14
+ 'America/Indiana/Winamac' => 'America/New_York',
15
+ 'America/Indiana/Marengo' => 'America/New_York',
16
+ 'America/Indiana/Petersburg' => 'America/New_York',
17
+ 'America/Indiana/Vevay' => 'America/New_York',
18
+ 'America/Chicago' => 'America/Chicago',
19
+ 'America/Indiana/Tell_City' => 'America/Chicago',
20
+ 'America/Indiana/Knox' => 'America/Chicago',
21
+ 'America/Menominee' => 'America/Chicago',
22
+ 'America/North_Dakota/Center' => 'America/Chicago',
23
+ 'America/North_Dakota/New_Salem' => 'America/Chicago',
24
+ 'America/North_Dakota/Beulah' => 'America/Chicago',
25
+ 'America/Denver' => 'America/Denver',
26
+ 'America/Boise' => 'America/Denver',
27
+ 'America/Phoenix' => 'America/Phoenix',
28
+ 'America/Los_Angeles' => 'America/Los_Angeles',
29
+ 'America/Anchorage' => 'America/Juneau',
30
+ 'America/Juneau' => 'America/Juneau',
31
+ 'America/Sitka' => 'America/Juneau',
32
+ 'America/Metlakatla' => 'America/Juneau',
33
+ 'America/Yakutat' => 'America/Juneau',
34
+ 'America/Nome' => 'America/Juneau',
35
+ 'Pacific/Honolulu' => 'Pacific/Honolulu',
36
+ 'America/Adak' => 'America/Adak'
37
+ }.freeze
38
+
39
+ # Converts the object into textual markup given a specific format.
40
+ #
41
+ # @param iana_timezone [String] the IANA/OLSON timezone you are trying to use, `'America/Boise'` as an example
42
+ # @return [String] the rails timezone that encapsulates the timezone you converted.
43
+ def rails_timezone_for(iana_timezone)
44
+ US_TIMEZONE_MAPPING[iana_timezone]
45
+ end
46
+
47
+ end
@@ -0,0 +1,31 @@
1
+ US_TIMEZONE_MAPPING = {
2
+ 'America/New_York' => 'America/New_York',
3
+ 'America/Detroit' => 'America/New_York',
4
+ 'America/Kentucky/Louisville' => 'America/New_York',
5
+ 'America/Kentucky/Monticello' => 'America/New_York',
6
+ 'America/Indiana/Indianapolis' => 'America/New_York',
7
+ 'America/Indiana/Vincennes' => 'America/New_York',
8
+ 'America/Indiana/Winamac' => 'America/New_York',
9
+ 'America/Indiana/Marengo' => 'America/New_York',
10
+ 'America/Indiana/Petersburg' => 'America/New_York',
11
+ 'America/Indiana/Vevay' => 'America/New_York',
12
+ 'America/Chicago' => 'America/Chicago',
13
+ 'America/Indiana/Tell_City' => 'America/Chicago',
14
+ 'America/Indiana/Knox' => 'America/Chicago',
15
+ 'America/Menominee' => 'America/Chicago',
16
+ 'America/North_Dakota/Center' => 'America/Chicago',
17
+ 'America/North_Dakota/New_Salem' => 'America/Chicago',
18
+ 'America/North_Dakota/Beulah' => 'America/Chicago',
19
+ 'America/Denver' => 'America/Denver',
20
+ 'America/Boise' => 'America/Denver',
21
+ 'America/Phoenix' => 'America/Phoenix',
22
+ 'America/Los_Angeles' => 'America/Los_Angeles',
23
+ 'America/Anchorage' => 'America/Juneau',
24
+ 'America/Juneau' => 'America/Juneau',
25
+ 'America/Sitka' => 'America/Juneau',
26
+ 'America/Metlakatla' => 'America/Juneau',
27
+ 'America/Yakutat' => 'America/Juneau',
28
+ 'America/Nome' => 'America/Juneau',
29
+ 'Pacific/Honolulu' => 'Pacific/Honolulu',
30
+ 'America/Adak' => 'America/Adak'
31
+ }.freeze
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iana_converter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Justin Karnes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
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.
15
+ A search for an existing solution showed that this has been an issue since the inception of ActiveSupport::Timezone as far back as 2012. Approaches which have been suggested included such ideas as: Making your own RTree in a spatially aware database and searching on boundaries, just don't use those timezones (yeah, that makes sense), rely on your users to set their own timezone (doesn't help if you do automated onboarding), find a better sourcing API for timezones based on GeoLookup (they almost all use OLSON/IANA).
16
+ Rather than doing any of those things, it made more sense to simply complete the mapping that ActiveSupport::Timezone started on and then seemingly abandoned.
17
+ email: justin@pefectcube.co
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/iana_converter.rb
23
+ - lib/mappings/us_mapping.rb
24
+ homepage: http://rubygems.org/gems/iana_converter
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.5.2
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Work around Rails timezone obfuscation of IANA/OLSON timezones
48
+ test_files: []