teasy 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Changelog.md +22 -0
- data/lib/teasy.rb +1 -1
- data/lib/teasy/time_with_zone.rb +7 -3
- data/lib/teasy/version.rb +1 -1
- data/test/teasy/time_with_zone_test.rb +3 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54eaaa8dd55d7a0240c794459cc5148dbbfcd60df28a1572036180df28047c2f
|
4
|
+
data.tar.gz: '079acda4b65773a09d6ad84a572218793e7dd1a92fe5c00677fe006de3de57c0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 955ca2cbca31f4efa789f0cef1a23a42b6a10ffbbc6796413449c61f7ab2c87598dbcfeffbca0aa2d7c83c163783b88d43c97edc010ea1fc4da4ec9c04a6716d
|
7
|
+
data.tar.gz: 9529e5ab26d1445a54931cb07907bf1e97ea2a03f36c5482f6a8458742f5e8c451dd55e923a9c33b8fb15a863b8b1fcaa10b675fa4daf0475671d555f85d4ea5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.1
|
data/Changelog.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
Please group changes into `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`
|
5
|
+
and `Security` as described in [Keep a Changelog](http://keepachangelog.com/),
|
6
|
+
taking the above order into account.
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
|
11
|
+
________________________________________________________________________________
|
12
|
+
|
13
|
+
## [0.2.4] - 2018-04-20
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- this Changelog
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- yield `zone` to block in `Teasy.with_zone`
|
20
|
+
- always use `Teasy.with_zone` internally when looking up the
|
21
|
+
`TZInfo::Timezone`. That way one could support other time zone names than the
|
22
|
+
TZInfo Identifier by making `Teasy.with_zone` convert those
|
data/lib/teasy.rb
CHANGED
data/lib/teasy/time_with_zone.rb
CHANGED
@@ -22,7 +22,7 @@ module Teasy
|
|
22
22
|
def initialize(year, month = nil, day = nil,
|
23
23
|
hour = nil, minute = nil, second = nil, usec_with_frac = nil,
|
24
24
|
zone = Teasy.default_zone)
|
25
|
-
@zone =
|
25
|
+
@zone = tzinfo_time_zone(zone)
|
26
26
|
@time = Time.utc(year, month, day, hour, minute, second, usec_with_frac)
|
27
27
|
@period = determine_period(@time, @zone)
|
28
28
|
end
|
@@ -53,7 +53,7 @@ module Teasy
|
|
53
53
|
|
54
54
|
def in_time_zone!(zone = Teasy.default_zone)
|
55
55
|
time = utc_time
|
56
|
-
@zone =
|
56
|
+
@zone = tzinfo_time_zone(zone)
|
57
57
|
@time = @zone.utc_to_local(time)
|
58
58
|
@period = @zone.period_for_utc(time)
|
59
59
|
remove_instance_variable(:@local_time) unless @local_time.nil?
|
@@ -74,7 +74,7 @@ module Teasy
|
|
74
74
|
|
75
75
|
def utc!
|
76
76
|
@time = @zone.local_to_utc(@time, @period.dst?)
|
77
|
-
@zone =
|
77
|
+
@zone = tzinfo_time_zone('UTC')
|
78
78
|
@period = @zone.period_for_local(@time)
|
79
79
|
self
|
80
80
|
end
|
@@ -207,6 +207,10 @@ module Teasy
|
|
207
207
|
|
208
208
|
format(string_format, sign, hours, minutes, seconds)
|
209
209
|
end
|
210
|
+
|
211
|
+
def tzinfo_time_zone(time_zone)
|
212
|
+
Teasy.with_zone(time_zone) { |zone| TZInfo::Timezone.get(zone) }
|
213
|
+
end
|
210
214
|
end
|
211
215
|
# rubocop:enable Metrics/ClassLength
|
212
216
|
end
|
data/lib/teasy/version.rb
CHANGED
@@ -44,7 +44,7 @@ class TimeWithZoneTest < Minitest::Test
|
|
44
44
|
|
45
45
|
def test_constructor_defaults_to_teasy_default_zone
|
46
46
|
assert_equal Teasy.default_zone, @timestamptz.zone
|
47
|
-
Teasy.
|
47
|
+
Teasy.with_zone('Europe/Berlin') do
|
48
48
|
timestamptz = Teasy::TimeWithZone.new(*@params)
|
49
49
|
assert_equal 'Europe/Berlin', timestamptz.zone
|
50
50
|
end
|
@@ -243,7 +243,7 @@ class TimeWithZoneTest < Minitest::Test
|
|
243
243
|
def test_inspect
|
244
244
|
assert_equal '2042-04-02 00:30:45 UTC', @timestamptz.inspect
|
245
245
|
assert_equal '2042-04-02 00:30:45 +0200', @timestamptz_berlin.inspect
|
246
|
-
timestamptz = Teasy.
|
246
|
+
timestamptz = Teasy.with_zone('Europe/Berlin') do
|
247
247
|
Teasy::TimeWithZone.new(2042)
|
248
248
|
end
|
249
249
|
assert_equal '2042-01-01 00:00:00 +0100', timestamptz.inspect
|
@@ -402,7 +402,7 @@ class TimeWithZoneTest < Minitest::Test
|
|
402
402
|
def test_to_s
|
403
403
|
assert_equal '2042-04-02 00:30:45 UTC', @timestamptz.to_s
|
404
404
|
assert_equal '2042-04-02 00:30:45 +0200', @timestamptz_berlin.to_s
|
405
|
-
timestamptz = Teasy.
|
405
|
+
timestamptz = Teasy.with_zone('Europe/Berlin') do
|
406
406
|
Teasy::TimeWithZone.new(2042)
|
407
407
|
end
|
408
408
|
assert_equal '2042-01-01 00:00:00 +0100', timestamptz.to_s
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Kuchenbecker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- ".gitignore"
|
123
123
|
- ".rubocop.yml"
|
124
124
|
- ".ruby-version"
|
125
|
+
- Changelog.md
|
125
126
|
- Gemfile
|
126
127
|
- LICENSE.txt
|
127
128
|
- README.md
|
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
158
|
version: '0'
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.7.
|
161
|
+
rubygems_version: 2.7.6
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: Teasy intends to make handling time zones easy.
|