dynamic_time_zone 0.2.0 → 0.4.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086e49015eb839845d138706fa36e5f5389db097bf2612df00f7fe50ea1e9dd8'
|
4
|
+
data.tar.gz: 9ca0f7741e769f1b679157744e3713737a982de3438a5e693b48d40b3edfbbc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecf0bdef79552069afce4a7bf669743679e3a64929ee858a10110b6d51d47b2c720f23cf767b86ac0352db5999322b584b7e78bb84b02d41060cfdc95683a46b
|
7
|
+
data.tar.gz: 59c876b2e3d98c82d0afb28a873fdbaa60dd83206ecb1575e257af45f86caa3b52b12d57e82bb95a4c3cfc8cc996de0df1937feb8b492113e2dfe016c927725b
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TimePatch
|
4
|
+
def compare_with_coercion(other)
|
5
|
+
if DynamicTimeZone.enabled && other.is_a?(ActiveSupport::TimeWithZone) && other.using_dynamic_time_zone?
|
6
|
+
self.utc <=> other.utc
|
7
|
+
else
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
alias_method :<=>, :compare_with_coercion
|
12
|
+
end
|
13
|
+
|
14
|
+
Time.prepend(TimePatch)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TimeWithZonePatch
|
4
|
+
def localtime(utc_offset = nil)
|
5
|
+
return super unless using_dynamic_time_zone?
|
6
|
+
|
7
|
+
utc + (utc_offset || 0).seconds
|
8
|
+
end
|
9
|
+
alias_method :getlocal, :localtime
|
10
|
+
|
11
|
+
def formatted_offset(*args)
|
12
|
+
using_dynamic_time_zone? ? '+0000' : super
|
13
|
+
end
|
14
|
+
|
15
|
+
def using_dynamic_time_zone?
|
16
|
+
DynamicTimeZone::Validator.new.valid?(time_zone.name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ActiveSupport::TimeWithZone.prepend(TimeWithZonePatch)
|
data/lib/dynamic_time_zone.rb
CHANGED
@@ -20,6 +20,7 @@ DynamicTimeZone.enabled = false
|
|
20
20
|
require 'dynamic_time_zone/validator'
|
21
21
|
require 'dynamic_time_zone/identifier_builder'
|
22
22
|
require 'dynamic_time_zone/time_zone_data_source'
|
23
|
-
require 'dynamic_time_zone/
|
23
|
+
require 'dynamic_time_zone/time_with_zone_patch'
|
24
|
+
require 'dynamic_time_zone/time_patch'
|
24
25
|
require 'dynamic_time_zone/offset_format_convertor'
|
25
26
|
require 'dynamic_time_zone/time_parser'
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Appfolio
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -44,25 +44,26 @@ dependencies:
|
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '6.1'
|
47
|
-
description:
|
48
|
-
email:
|
47
|
+
description:
|
48
|
+
email:
|
49
49
|
executables: []
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- lib/dynamic_time_zone.rb
|
54
54
|
- lib/dynamic_time_zone/identifier_builder.rb
|
55
|
-
- lib/dynamic_time_zone/localtime_patch.rb
|
56
55
|
- lib/dynamic_time_zone/offset_format_convertor.rb
|
57
56
|
- lib/dynamic_time_zone/test_helper.rb
|
58
57
|
- lib/dynamic_time_zone/time_parser.rb
|
58
|
+
- lib/dynamic_time_zone/time_patch.rb
|
59
|
+
- lib/dynamic_time_zone/time_with_zone_patch.rb
|
59
60
|
- lib/dynamic_time_zone/time_zone_data_source.rb
|
60
61
|
- lib/dynamic_time_zone/validator.rb
|
61
62
|
- lib/dynamic_time_zone/version.rb
|
62
63
|
homepage: https://github.com/appfolio/dynamic_time_zone
|
63
64
|
licenses: []
|
64
65
|
metadata: {}
|
65
|
-
post_install_message:
|
66
|
+
post_install_message:
|
66
67
|
rdoc_options: []
|
67
68
|
require_paths:
|
68
69
|
- lib
|
@@ -77,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.1.
|
81
|
-
signing_key:
|
81
|
+
rubygems_version: 3.1.6
|
82
|
+
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: Dynamically set the offset from UTC from timezone identifier
|
84
85
|
test_files: []
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module LocaltimePatch
|
4
|
-
def localtime(utc_offset = nil)
|
5
|
-
return super unless DynamicTimeZone.enabled
|
6
|
-
|
7
|
-
utc + (utc_offset || 0).seconds
|
8
|
-
end
|
9
|
-
alias_method :getlocal, :localtime
|
10
|
-
end
|
11
|
-
|
12
|
-
ActiveSupport::TimeWithZone.prepend(LocaltimePatch)
|