dynamic_time_zone 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 706d40312d1aa37f500bdc8665b2506f0362932688f541f8bee1b417db6e87af
4
- data.tar.gz: dc2df835bf9c463af7bad2d66490826120b49629ef739a9ce000ee5fc217fc82
3
+ metadata.gz: e152a6e5525dce62aaede5ae0ed1c0f3fb28f0f94d19625e3e0c44089411816d
4
+ data.tar.gz: 296a3a52c5a8df087faad008ab833f8f65db5c27f996db4b4352ab4dbff61821
5
5
  SHA512:
6
- metadata.gz: 39c0b0b44c62e3eee271fd765f421e9e18248abdc9957698a1609d8ece2aac61eef388e33bdb4d8fd0dcaa4392ca7597ba81893ba33020c8f8e8af7041c73118
7
- data.tar.gz: afa2b30e79e8ed122085e3f74cae4a201e86cae37a56bb52878308d4d71a0574ff5b4ddec097ef17a1ad7228e8d8c7573d255aae4758d755ca15863568a7951e
6
+ metadata.gz: dd13a196d08032de14bf8104ee2a4bc95238521c6a02d301424bb17ee2961e57e7df439571b2294a183dc136618fec9832bbdd814eb4c7d9f9eaf36e8892f3a2
7
+ data.tar.gz: 4d28f221c73f675d34469462b74906d94ea1cee53ca257387bfa7b126e2e152c222471803ea608bacbd5f1887afd3be4d4904c6e8e4d3fe90f0158cbcf606641
@@ -21,3 +21,5 @@ require 'dynamic_time_zone/validator'
21
21
  require 'dynamic_time_zone/identifier_builder'
22
22
  require 'dynamic_time_zone/time_zone_data_source'
23
23
  require 'dynamic_time_zone/localtime_patch'
24
+ require 'dynamic_time_zone/offset_format_convertor'
25
+ require 'dynamic_time_zone/time_parser'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DynamicTimeZone
4
+ class OffsetFormatConvertor
5
+ def from_hour_minutes(hour_minutes)
6
+ hour = (hour_minutes / 100).floor
7
+ minutes = (hour_minutes % 100)
8
+ hour * 3600 + minutes * 60
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DynamicTimeZone
4
+ class TimeParser
5
+ def parse(time_string)
6
+ raw_parts = time_string.split(' ')
7
+ return DateTime.parse(time_string) unless raw_parts.length == 3 && (raw_parts.last.start_with?('+') || raw_parts.last.start_with?('-'))
8
+
9
+ date_part = raw_parts[0]
10
+ time_part = raw_parts[1]
11
+ offset_part = raw_parts[2]
12
+ offset_sign = offset_part[0]
13
+ offset_amount_hour_minutes = offset_part[1..].to_i
14
+ offset_seconds = DynamicTimeZone::OffsetFormatConvertor.new.from_hour_minutes(offset_amount_hour_minutes)
15
+
16
+ ActiveSupport::TimeZone.new("DynamicTimeZone/#{offset_sign}#{offset_seconds}")
17
+ .parse("#{date_part} #{time_part}")
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicTimeZone
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_time_zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Appfolio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -53,7 +53,9 @@ files:
53
53
  - lib/dynamic_time_zone.rb
54
54
  - lib/dynamic_time_zone/identifier_builder.rb
55
55
  - lib/dynamic_time_zone/localtime_patch.rb
56
+ - lib/dynamic_time_zone/offset_format_convertor.rb
56
57
  - lib/dynamic_time_zone/test_helper.rb
58
+ - lib/dynamic_time_zone/time_parser.rb
57
59
  - lib/dynamic_time_zone/time_zone_data_source.rb
58
60
  - lib/dynamic_time_zone/validator.rb
59
61
  - lib/dynamic_time_zone/version.rb
@@ -75,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
77
  - !ruby/object:Gem::Version
76
78
  version: '0'
77
79
  requirements: []
78
- rubygems_version: 3.0.8
80
+ rubygems_version: 3.1.4
79
81
  signing_key:
80
82
  specification_version: 4
81
83
  summary: Dynamically set the offset from UTC from timezone identifier