teasy 0.2.3 → 0.2.4

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: 2de5ae5fd3b0dda6d2e663589ef9bbaed872dd9777dedb1d4a66e5c6fd5ec784
4
- data.tar.gz: 2eff70a6be7c0aae001355a4373060d61cc0083593724e9adda781c46d7db4f2
3
+ metadata.gz: 54eaaa8dd55d7a0240c794459cc5148dbbfcd60df28a1572036180df28047c2f
4
+ data.tar.gz: '079acda4b65773a09d6ad84a572218793e7dd1a92fe5c00677fe006de3de57c0'
5
5
  SHA512:
6
- metadata.gz: 1767af8c4df3f4c23d50a510364d689ae693ab4cf69148238e3d4b30f86fec9f2c461023d2c31a8b65c62abf5defcde10c55db872f133f543d9561896ba83ae1
7
- data.tar.gz: 8be5bd06ef3fad9d0cf60c922a4cd1a4516e881551b0782f9b33bd9f362d3f287b03c136919f0a6f67e52d31a54ddc45b1d66c82e3917b5f0e45fd918827deed
6
+ metadata.gz: 955ca2cbca31f4efa789f0cef1a23a42b6a10ffbbc6796413449c61f7ab2c87598dbcfeffbca0aa2d7c83c163783b88d43c97edc010ea1fc4da4ec9c04a6716d
7
+ data.tar.gz: 9529e5ab26d1445a54931cb07907bf1e97ea2a03f36c5482f6a8458742f5e8c451dd55e923a9c33b8fb15a863b8b1fcaa10b675fa4daf0475671d555f85d4ea5
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
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
@@ -22,7 +22,7 @@ module Teasy
22
22
  def with_zone(zone)
23
23
  old_zone = default_zone
24
24
  self.default_zone = zone
25
- yield
25
+ yield zone
26
26
  ensure
27
27
  self.default_zone = old_zone
28
28
  end
@@ -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 = TZInfo::Timezone.get(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 = TZInfo::Timezone.get(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 = TZInfo::Timezone.get('UTC')
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teasy
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
@@ -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.stub(:default_zone, 'Europe/Berlin') do
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.stub(:default_zone, 'Europe/Berlin') do
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.stub(:default_zone, 'Europe/Berlin') do
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.3
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-03-26 00:00:00.000000000 Z
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.3
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.