teasy 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -4
- data/.ruby-version +1 -1
- data/lib/teasy/floating_time.rb +1 -1
- data/lib/teasy/time_with_zone.rb +11 -8
- data/lib/teasy/version.rb +1 -1
- data/teasy.gemspec +6 -7
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8bbffed19dc702847e0096485c0540b12ec6b28e4f5a14165ccb46ae13103a6
|
4
|
+
data.tar.gz: cc76f08f0630726cfc371ea2a4bc8142a4245f408ca5a358e544781e4d4b812a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d00df4b7245a715e319eefefa17392d9e5068a289937e8978d52b2e690b6368c79e1289a8f98b86cbbc9b7397ec636047837ccb7f74c6d544b553bbec2aa25b
|
7
|
+
data.tar.gz: d5d3c5d28d40941738d7ad3ac272c980993abe0e4dd1640d032755238bb7f1b9014653fb389ef9f875cca9c92ba194940097e46f4c6de04fc6614bec78c2e29c
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
3
|
- teasy.gemspec
|
4
|
-
-
|
5
|
-
-
|
4
|
+
- "vendor/**/*"
|
5
|
+
- "test/**/*"
|
6
|
+
NewCops: enable
|
6
7
|
|
7
8
|
# Setting the line length to a maximum of 80 chars.
|
8
|
-
LineLength:
|
9
|
+
Layout/LineLength:
|
9
10
|
Enabled: true
|
10
11
|
Max: 80
|
11
|
-
Documentation:
|
12
|
+
Style/Documentation:
|
12
13
|
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/lib/teasy/floating_time.rb
CHANGED
@@ -114,7 +114,7 @@ module Teasy
|
|
114
114
|
|
115
115
|
def prefix_zone_info(format)
|
116
116
|
# prefixes zone directives with a % s.t. they are ignored in strftime
|
117
|
-
format.gsub(zone_directives_matcher) { |m|
|
117
|
+
format.gsub(zone_directives_matcher) { |m| "%#{m}" }
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
data/lib/teasy/time_with_zone.rb
CHANGED
@@ -55,7 +55,7 @@ module Teasy
|
|
55
55
|
@zone = tzinfo_time_zone(zone)
|
56
56
|
@time = @zone.utc_to_local(time)
|
57
57
|
@period = @zone.period_for_utc(time)
|
58
|
-
remove_instance_variable(:@local_time)
|
58
|
+
remove_instance_variable(:@local_time) if defined?(@local_time)
|
59
59
|
self
|
60
60
|
end
|
61
61
|
|
@@ -142,7 +142,7 @@ module Teasy
|
|
142
142
|
end
|
143
143
|
|
144
144
|
def to_time
|
145
|
-
return @local_time
|
145
|
+
return @local_time if defined?(@local_time)
|
146
146
|
|
147
147
|
params = %i[year mon day hour min].map! { |m| @time.send(m) }
|
148
148
|
params << @time.sec + @time.subsec
|
@@ -196,18 +196,21 @@ module Teasy
|
|
196
196
|
format_with_zone
|
197
197
|
end
|
198
198
|
|
199
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
199
200
|
def formatted_offset(offset_in_seconds, colon = false, seconds = false)
|
200
|
-
string_format = +'%s%02d:%02d'
|
201
|
-
string_format.concat(':%02d') if seconds
|
202
|
-
string_format.delete!(':') unless colon
|
203
|
-
|
204
201
|
sign = offset_in_seconds.negative? ? '-' : '+'
|
205
202
|
hours = offset_in_seconds.abs / 3600
|
206
203
|
minutes = (offset_in_seconds.abs % 3600) / 60
|
207
|
-
seconds = (offset_in_seconds.abs % 60)
|
208
204
|
|
209
|
-
|
205
|
+
separator = colon ? ':' : ''
|
206
|
+
string_format = ['%s%02d', '%02d', ('%02d' if seconds)]
|
207
|
+
.compact.join(separator)
|
208
|
+
args = [sign, hours, minutes, ((offset_in_seconds.abs % 60) if seconds)]
|
209
|
+
.compact
|
210
|
+
|
211
|
+
format(string_format, *args)
|
210
212
|
end
|
213
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
211
214
|
|
212
215
|
def tzinfo_time_zone(time_zone)
|
213
216
|
Teasy.with_zone(time_zone) { |zone| TZInfo::Timezone.get(zone) }
|
data/lib/teasy/version.rb
CHANGED
data/teasy.gemspec
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
|
2
|
-
require File.expand_path("../lib/teasy/version", __FILE__)
|
1
|
+
require File.expand_path('lib/teasy/version', __dir__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |spec|
|
5
4
|
spec.name = 'teasy'
|
6
5
|
spec.version = Teasy::VERSION
|
7
6
|
spec.authors = ['Kai Kuchenbecker']
|
8
7
|
spec.email = ['Kai.Kuchenbecker@invision.de']
|
9
|
-
spec.summary =
|
10
|
-
spec.description =
|
8
|
+
spec.summary = 'Teasy intends to make handling time zones easy.'
|
9
|
+
spec.description = "Teasy builds on tzinfo to get time zone data and
|
11
10
|
provides time classes to ease working with time zones.
|
12
11
|
It provides TimeWithZone which is similiar to Rails'
|
13
12
|
ActiveSupport::TimeWithZone but with less quirks. And
|
14
13
|
it provides FloatingTime which is time without a zone.
|
15
|
-
|
14
|
+
"
|
16
15
|
spec.homepage = ''
|
17
16
|
spec.license = 'MIT'
|
18
17
|
|
@@ -22,11 +21,11 @@ Gem::Specification.new do |spec|
|
|
22
21
|
spec.required_ruby_version = '> 2.0'
|
23
22
|
|
24
23
|
spec.add_runtime_dependency 'tzinfo', '~> 2.0'
|
25
|
-
spec.add_runtime_dependency 'tzinfo-data', '~> 1.
|
24
|
+
spec.add_runtime_dependency 'tzinfo-data', '~> 1.2020.1'
|
26
25
|
|
27
26
|
spec.add_development_dependency 'bundler'
|
28
|
-
spec.add_development_dependency 'rake'
|
29
27
|
spec.add_development_dependency 'minitest'
|
30
28
|
spec.add_development_dependency 'minitest-reporters'
|
29
|
+
spec.add_development_dependency 'rake'
|
31
30
|
spec.add_development_dependency 'rubocop'
|
32
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teasy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Kuchenbecker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.2020.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.2020.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest
|
70
|
+
name: minitest-reporters
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.1.2
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Teasy intends to make handling time zones easy.
|