teasy 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8c029c09c43c7d2f53444146e45352eea16c00a0
4
+ data.tar.gz: c18c15ff0af658d6f561121b2747e3e46258e95a
5
+ SHA512:
6
+ metadata.gz: e3bb7266d199fcecf2c9a245c57a5fff334500f0e096d7e46adf81b8d8762b836ade69a5d5763007d3e8102af719fa5d9e7be47424aecb430ad238c014a8f956
7
+ data.tar.gz: e207e2590e5636eb06e76f7949d777eaba7a6c36fc7a61567c0d500c0507c67bf48016e9c1e18d1e10e18edc7d7b24195720567a7f25de10a6b36b7220e51394
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ Exclude:
3
+ - teasy.gemspec
4
+ - 'vendor/**/*'
5
+ - 'test/**/*'
6
+
7
+ # Setting the line length to a maximum of 80 chars.
8
+ LineLength:
9
+ Enabled: true
10
+ Max: 80
11
+ Documentation:
12
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in teasy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Kai Kuchenbecker
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Teasy
2
+
3
+ Timezone handling made easy.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'teasy'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install teasy
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/teasy/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubocop/rake_task'
2
+ require 'rake/testtask'
3
+ require 'bundler/gem_tasks'
4
+
5
+ RuboCop::RakeTask.new
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ t.pattern = 'test/**/*_test.rb'
9
+ end
10
+
11
+ task default: [:test, :rubocop]
data/lib/teasy.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'teasy/version'
2
+ require 'teasy/time_with_zone'
3
+ require 'teasy/floating_time'
4
+
5
+ module Teasy
6
+ def self.default_zone
7
+ Thread.current[:teasy_default_zone] ||= 'UTC'
8
+ end
9
+
10
+ def self.default_zone=(zone)
11
+ Thread.current[:teasy_default_zone] = zone
12
+ end
13
+
14
+ def self.with_zone(zone)
15
+ old_zone = Thread.current[:teasy_default_zone]
16
+ Thread.current[:teasy_default_zone] = zone
17
+ yield
18
+ Thread.current[:teasy_default_zone] = old_zone
19
+ end
20
+ end
@@ -0,0 +1,114 @@
1
+ require 'tzinfo'
2
+ require 'forwardable'
3
+
4
+ module Teasy
5
+ class FloatingTime
6
+ extend Forwardable
7
+ include Comparable
8
+
9
+ def_delegators :time, :year, :mon, :month, :day, :hour, :min, :minute, :sec,
10
+ :usec, :nsec, :subsec, :mday, :wday, :yday, :monday?,
11
+ :tuesday?, :wednesday?, :thursday?, :friday?, :saturday?,
12
+ :sunday?
13
+
14
+ # rubocop:disable Metrics/ParameterLists
15
+ def initialize(year, month = nil, day = nil,
16
+ hour = nil, minute = nil, second = nil, usec_with_frac = nil)
17
+ @time = Time.utc(year, month, day, hour, minute, second, usec_with_frac)
18
+ end
19
+ # rubocop:enable Metrics/ParameterLists
20
+
21
+ def self.from_time(time)
22
+ new(time.year, time.mon, time.day,
23
+ time.hour, time.min, time.sec, time.nsec / 1_000.0)
24
+ end
25
+
26
+ def round!(*args)
27
+ @time = time.round(*args)
28
+ self
29
+ end
30
+
31
+ def round(*args)
32
+ dup.round!(*args)
33
+ end
34
+
35
+ def inspect
36
+ strftime('%Y-%m-%d %H:%M:%S')
37
+ end
38
+
39
+ alias_method :to_s, :inspect
40
+
41
+ def strftime(format)
42
+ format = prefix_zone_info(format) if includes_zone_directive?(format)
43
+ time.strftime(format)
44
+ end
45
+
46
+ def asctime
47
+ strftime('%a %b %e %T %Y')
48
+ end
49
+
50
+ alias_method :ctime, :asctime
51
+
52
+ def <=>(other)
53
+ return nil unless other.respond_to?(:to_time) &&
54
+ other.respond_to?(:utc_offset)
55
+ to_time - other.utc_offset <=> other.to_time.utc
56
+ end
57
+
58
+ def eql?(other)
59
+ hash == other.hash
60
+ end
61
+
62
+ def hash
63
+ (to_a << self.class).hash
64
+ end
65
+
66
+ def +(other)
67
+ FloatingTime.from_time(time + other)
68
+ end
69
+
70
+ def -(other)
71
+ if other.is_a? Numeric
72
+ FloatingTime.from_time(time - other)
73
+ elsif other.respond_to? :to_time
74
+ to_time - other.to_time
75
+ else
76
+ fail TypeError, "#{other.class} can't be coerced into FloatingTime"
77
+ end
78
+ end
79
+
80
+ def to_a
81
+ time.to_a[0..7]
82
+ end
83
+
84
+ def to_time
85
+ time.dup
86
+ end
87
+
88
+ alias_method :utc, :to_time
89
+
90
+ def utc_offset
91
+ 0
92
+ end
93
+
94
+ private
95
+
96
+ attr_reader :time
97
+
98
+ def self.zone_directives_matcher
99
+ @zone_directives_matcher ||= Regexp.union(
100
+ /(?<!%)%Z/, /(?<!%)%z/, /(?<!%)%:z/, /(?<!%)%::z/
101
+ )
102
+ end
103
+
104
+ def includes_zone_directive?(format)
105
+ FloatingTime.zone_directives_matcher =~ format
106
+ end
107
+
108
+ def prefix_zone_info(format)
109
+ # prefixes zone directives with a % s.t. they are ignored in strftime
110
+ format.gsub(FloatingTime.zone_directives_matcher) { |m| '%' + m }
111
+ end
112
+ end
113
+ # rubocop:enable Metrics/ClassLength
114
+ end
@@ -0,0 +1,175 @@
1
+ require 'tzinfo'
2
+ require 'forwardable'
3
+
4
+ module Teasy
5
+ # rubocop:disable Metrics/ClassLength
6
+ class TimeWithZone
7
+ extend Forwardable
8
+ include Comparable
9
+
10
+ def_delegators :time, :year, :mon, :month, :day, :hour, :min, :minute, :sec,
11
+ :usec, :nsec, :subsec, :mday, :wday, :yday, :monday?,
12
+ :tuesday?, :wednesday?, :thursday?, :friday?, :saturday?,
13
+ :sunday?
14
+ def_delegators :period, :dst?
15
+ def_delegator :period, :utc_total_offset, :utc_offset
16
+ def_delegators :to_time, :to_i, :to_r, :to_f
17
+
18
+ # rubocop:disable Metrics/ParameterLists
19
+ def initialize(year, month = nil, day = nil,
20
+ hour = nil, minute = nil, second = nil, usec_with_frac = nil,
21
+ zone = Teasy.default_zone)
22
+ @zone = TZInfo::Timezone.get(zone)
23
+ @time = Time.utc(year, month, day, hour, minute, second, usec_with_frac)
24
+ @period = @zone.period_for_local(@time)
25
+ end
26
+ # rubocop:enable Metrics/ParameterLists
27
+
28
+ def self.from_time(time, zone = Teasy.default_zone)
29
+ new(time.year, time.mon, time.day, time.hour, time.min, time.sec,
30
+ time.nsec / 1_000.0, zone)
31
+ end
32
+
33
+ def self.from_utc(utc_time, zone = Teasy.default_zone)
34
+ from_time(utc_time, 'UTC').in_time_zone!(zone)
35
+ end
36
+
37
+ def in_time_zone!(zone = Teasy.default_zone)
38
+ time = to_time
39
+ @zone = TZInfo::Timezone.get(zone)
40
+ @time = @zone.utc_to_local(time)
41
+ @period = @zone.period_for_utc(time)
42
+ self
43
+ end
44
+
45
+ def in_time_zone(zone = Teasy.default_zone)
46
+ dup.in_time_zone!(zone)
47
+ end
48
+
49
+ def zone
50
+ @zone.identifier
51
+ end
52
+
53
+ def utc?
54
+ @zone.identifier == 'UTC'
55
+ end
56
+
57
+ def utc!
58
+ @time = @zone.local_to_utc(@time)
59
+ @zone = TZInfo::Timezone.get('UTC')
60
+ @period = @zone.period_for_local(@time)
61
+ self
62
+ end
63
+
64
+ def utc
65
+ dup.utc!
66
+ end
67
+
68
+ def round!(*args)
69
+ @time = @time.round(*args)
70
+ self
71
+ end
72
+
73
+ def round(*args)
74
+ dup.round!(*args)
75
+ end
76
+
77
+ def inspect
78
+ format = utc? ? '%Y-%m-%d %H:%M:%S %Z' : '%Y-%m-%d %H:%M:%S %z'
79
+ strftime(format)
80
+ end
81
+
82
+ alias_method :to_s, :inspect
83
+
84
+ def strftime(format)
85
+ format = replace_zone_info(format) if includes_zone_directive?(format)
86
+ time.strftime(format)
87
+ end
88
+
89
+ def asctime
90
+ strftime('%a %b %e %T %Y')
91
+ end
92
+
93
+ alias_method :ctime, :asctime
94
+
95
+ def +(other)
96
+ TimeWithZone.from_utc(to_time + other, @zone.identifier)
97
+ end
98
+
99
+ def -(other)
100
+ if other.is_a? Numeric
101
+ TimeWithZone.from_utc(to_time - other, @zone.identifier)
102
+ elsif other.respond_to? :to_time
103
+ to_time - other.to_time
104
+ else
105
+ fail TypeError, "#{other.class} can't be coerced into TimeWithZone"
106
+ end
107
+ end
108
+
109
+ def <=>(other)
110
+ return nil unless other.respond_to? :to_time
111
+ to_time <=> other.to_time
112
+ end
113
+
114
+ def eql?(other)
115
+ hash == other.hash
116
+ end
117
+
118
+ def hash
119
+ (utc.to_a << self.class).hash
120
+ end
121
+
122
+ def to_a
123
+ time.to_a[0..7] + [dst?, period.abbreviation.to_s]
124
+ end
125
+
126
+ def to_time
127
+ @utc_time ||= @zone.local_to_utc(@time)
128
+ end
129
+
130
+ private
131
+
132
+ attr_reader :time, :period
133
+
134
+ # matches valid format directives for zones
135
+ ZONE_ABBREV = /(?<!%)%Z/
136
+ ZONE_NO_COLON_OFFSET = /(?<!%)%z/
137
+ ZONE_COLON_OFFSET = /(?<!%)%:z/
138
+ ZONE_COLONS_OFFSET = /(?<!%)%::z/
139
+
140
+ def self.zone_directives_matcher
141
+ @zone_directives_matcher ||= Regexp.union(
142
+ ZONE_ABBREV, ZONE_NO_COLON_OFFSET, ZONE_COLON_OFFSET, ZONE_COLONS_OFFSET
143
+ )
144
+ end
145
+
146
+ def includes_zone_directive?(format)
147
+ TimeWithZone.zone_directives_matcher =~ format
148
+ end
149
+
150
+ def replace_zone_info(format)
151
+ format_with_zone = format.gsub(ZONE_ABBREV, period.abbreviation.to_s)
152
+ format_with_zone.gsub!(ZONE_NO_COLON_OFFSET, formatted_offset(utc_offset))
153
+ format_with_zone.gsub!(
154
+ ZONE_COLON_OFFSET, formatted_offset(utc_offset, :with_colon))
155
+ format_with_zone.gsub!(
156
+ ZONE_COLONS_OFFSET,
157
+ formatted_offset(utc_offset, :with_colon, :with_seconds))
158
+ format_with_zone
159
+ end
160
+
161
+ def formatted_offset(offset_in_seconds, colon = false, seconds = false)
162
+ string_format = '%s%02d:%02d'
163
+ string_format.concat(':%02d') if seconds
164
+ string_format.delete!(':') unless colon
165
+
166
+ sign = offset_in_seconds < 0 ? '-' : '+'
167
+ hours = offset_in_seconds.abs / 3600
168
+ minutes = (offset_in_seconds.abs % 3600) / 60
169
+ seconds = (offset_in_seconds.abs % 60)
170
+
171
+ format(string_format, sign, hours, minutes, seconds)
172
+ end
173
+ end
174
+ # rubocop:enable Metrics/ClassLength
175
+ end
@@ -0,0 +1,3 @@
1
+ module Teasy
2
+ VERSION = '0.0.1'
3
+ end
data/teasy.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ require_relative 'lib/teasy/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'teasy'
6
+ spec.version = Teasy::VERSION
7
+ spec.authors = ['Kai Kuchenbecker']
8
+ spec.email = ['Kai.Kuchenbecker@invision.de']
9
+ spec.summary = %q{Teasy intends to make handling time zones easy.}
10
+ spec.description = %q{Teasy builds on tzinfo to get time zone data and
11
+ provides time classes to ease working with time zones.
12
+ It provides TimeWithZone which is similiar to Rails'
13
+ ActiveSupport::TimeWithZone but with less quirks. And
14
+ it provides FloatingTime which is time without a zone.
15
+ }
16
+ spec.homepage = ''
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_runtime_dependency 'tzinfo', '~> 1.2'
25
+ spec.add_runtime_dependency 'tzinfo-data', '~> 1.2015.1'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.6'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'minitest'
30
+ spec.add_development_dependency 'minitest-reporters'
31
+ spec.add_development_dependency 'rubocop'
32
+ end
@@ -0,0 +1,214 @@
1
+ require 'test_helper'
2
+
3
+ class FloatingTimeTest < Minitest::Test
4
+ def setup
5
+ @params = [2042, 4, 2, 0, 30, 45, 1.112]
6
+ @timestamp = Teasy::FloatingTime.new(*@params)
7
+ end
8
+
9
+ def test_constructor_parameter
10
+ assert_equal 2042, @timestamp.year
11
+ assert_equal 4, @timestamp.month
12
+ assert_equal 2, @timestamp.day
13
+ assert_equal 0, @timestamp.hour
14
+ assert_equal 30, @timestamp.min
15
+ assert_equal 45, @timestamp.sec
16
+ assert_equal 1_112, @timestamp.nsec
17
+ end
18
+
19
+ def test_from_time
20
+ time = Time.new(*@params)
21
+ timestamp = Teasy::FloatingTime.from_time(time)
22
+ assert_instance_of Teasy::FloatingTime, timestamp
23
+ assert_equal 0, timestamp.hour
24
+ end
25
+
26
+ def test_addition
27
+ assert_equal 45, @timestamp.sec
28
+ @timestamp += 5
29
+ assert_equal 50, @timestamp.sec
30
+ assert_instance_of Teasy::FloatingTime, @timestamp
31
+ end
32
+
33
+ def test_subtraction
34
+ assert_equal 45, @timestamp.sec
35
+ @timestamp -= 5
36
+ assert_equal 40, @timestamp.sec
37
+ assert_instance_of Teasy::FloatingTime, @timestamp
38
+ assert_instance_of Float, @timestamp - @timestamp
39
+ assert_equal 5.0, @timestamp - (@timestamp - 5)
40
+ end
41
+
42
+ def test_comparison
43
+ timestamptz = Teasy::TimeWithZone.new(*@params, 'America/New_York')
44
+ assert_operator @timestamp, :==, @timestamp
45
+ assert_operator @timestamp, :==, Teasy::TimeWithZone.new(*@params)
46
+ assert_operator @timestamp, :==, timestamptz
47
+ refute_operator @timestamp, :==, timestamptz.utc
48
+ assert_operator @timestamp, :>, (@timestamp - 1800)
49
+ assert_operator @timestamp, :>, timestamptz.in_time_zone('America/Chicago')
50
+ assert_operator @timestamp, :<, (@timestamp + 1800)
51
+ assert_operator @timestamp, :<, timestamptz.in_time_zone('Asia/Calcutta')
52
+ end
53
+
54
+ def test_asctime
55
+ assert_equal 'Wed Apr 2 00:30:45 2042', @timestamp.asctime
56
+ end
57
+
58
+ def test_ctime
59
+ assert_equal 'Wed Apr 2 00:30:45 2042', @timestamp.ctime
60
+ end
61
+
62
+ def test_day
63
+ assert_equal 2, @timestamp.day
64
+ assert_equal 2, @timestamp.mday
65
+ end
66
+
67
+ def test_eql?
68
+ assert @timestamp.eql?(@timestamp)
69
+ refute @timestamp.eql?(@timestamp + 1)
70
+ refute @timestamp.eql?(Teasy::TimeWithZone.new(*@params, 'Europe/Berlin'))
71
+ end
72
+
73
+ def test_friday?
74
+ friday = Teasy::FloatingTime.new(2042, 04, 04)
75
+ assert_equal true, friday.friday?
76
+ assert_equal false, @timestamp.friday?
77
+ end
78
+
79
+ def test_hash
80
+ assert_equal @timestamp.hash, @timestamp.dup.hash
81
+ refute_equal @timestamp.hash, (@timestamp + 1).hash
82
+ refute_equal @timestamp.hash, (Teasy::TimeWithZone.new(*@params)).hash
83
+ end
84
+
85
+ def test_hour
86
+ assert_equal 0, @timestamp.hour
87
+ end
88
+
89
+ def test_inspect
90
+ assert_equal '2042-04-02 00:30:45', @timestamp.inspect
91
+ end
92
+
93
+ def test_min
94
+ assert_equal 30, @timestamp.min
95
+ end
96
+
97
+ def test_month
98
+ assert_equal 4, @timestamp.month
99
+ assert_equal 3, (@timestamp - 100_000).month
100
+ end
101
+
102
+ def test_mon
103
+ assert_equal 4, @timestamp.mon
104
+ assert_equal 3, (@timestamp - 100_000).mon
105
+ end
106
+
107
+ def test_monday?
108
+ monday = Teasy::FloatingTime.new(2042, 03, 31)
109
+ assert_equal true, monday.monday?
110
+ assert_equal false, @timestamp.monday?
111
+ end
112
+
113
+ def test_nsec
114
+ assert_equal 1_112, @timestamp.nsec
115
+ end
116
+
117
+ def test_round
118
+ assert_instance_of Teasy::FloatingTime, @timestamp.round
119
+ assert_equal 1_112, @timestamp.nsec
120
+ assert_equal 0, @timestamp.round.nsec
121
+ assert_equal 1_100, @timestamp.round(7).nsec
122
+ assert_equal 1_112, @timestamp.round(9).nsec
123
+ end
124
+
125
+ def test_round!
126
+ assert_equal 1_112, @timestamp.nsec
127
+ assert_equal 1_112, @timestamp.round!(9).nsec
128
+ assert_equal 1_110, @timestamp.round!(8).nsec
129
+ assert_equal 1_100, @timestamp.round!(7).nsec
130
+ assert_equal 1_000, @timestamp.round!(6).nsec
131
+ assert_equal 0, @timestamp.round!.nsec
132
+ assert_instance_of Teasy::FloatingTime, @timestamp.round!
133
+ assert_equal @timestamp.object_id, @timestamp.round!.object_id
134
+ end
135
+
136
+ def test_saturday?
137
+ saturday = Teasy::FloatingTime.new(2042, 4, 5)
138
+ assert_equal true, saturday.saturday?
139
+ assert_equal false, @timestamp.saturday?
140
+ end
141
+
142
+ def test_sec
143
+ assert_equal 45, @timestamp.sec
144
+ assert_equal 50, (@timestamp + 5).sec
145
+ end
146
+
147
+ def test_strftime
148
+ assert_equal '00', @timestamp.strftime('%H')
149
+ assert_equal '00 %z', @timestamp.strftime('%H %z')
150
+ assert_equal '00 %:z', @timestamp.strftime('%H %:z')
151
+ assert_equal '00 %::z', @timestamp.strftime('%H %::z')
152
+ assert_equal '00 %Z', @timestamp.strftime('%H %Z')
153
+ assert_equal '00 %Z', @timestamp.strftime('%H %%Z')
154
+ end
155
+
156
+ def test_subsec
157
+ assert_equal 1.112.to_r / 1_000_000, @timestamp.subsec
158
+ end
159
+
160
+ def test_sunday?
161
+ sunday = Teasy::FloatingTime.new(2042, 4, 6)
162
+ assert_equal true, sunday.sunday?
163
+ assert_equal false, @timestamp.sunday?
164
+ end
165
+
166
+ def test_thursday?
167
+ thursday = Teasy::FloatingTime.new(2042, 4, 3)
168
+ assert_equal true, thursday.thursday?
169
+ assert_equal false, @timestamp.thursday?
170
+ end
171
+
172
+ def test_to_a
173
+ assert_equal [45, 30, 0, 2, 4, 2042, 3, 92], @timestamp.to_a
174
+ end
175
+
176
+ def test_to_s
177
+ assert_equal '2042-04-02 00:30:45', @timestamp.to_s
178
+ end
179
+
180
+ def test_tuesday?
181
+ tuesday = Teasy::FloatingTime.new(2042, 4, 1)
182
+ assert_equal true, tuesday.tuesday?
183
+ assert_equal false, @timestamp.tuesday?
184
+ end
185
+
186
+ def test_usec
187
+ assert_equal 1, @timestamp.usec
188
+ end
189
+
190
+ def test_utc
191
+ utc_time = @timestamp.utc
192
+ assert_instance_of Time, utc_time
193
+ assert utc_time.utc?
194
+ assert_equal '2042-04-02 00:30:45', utc_time.strftime('%F %T')
195
+ assert_equal @timestamp, utc_time
196
+ end
197
+
198
+ def test_wday
199
+ assert_equal 3, @timestamp.wday
200
+ end
201
+
202
+ def test_wednesday?
203
+ assert_equal true, @timestamp.wednesday?
204
+ assert_equal false, (@timestamp + 86_400).wednesday?
205
+ end
206
+
207
+ def test_yday
208
+ assert_equal 92, @timestamp.yday
209
+ end
210
+
211
+ def test_year
212
+ assert_equal 2042, @timestamp.year
213
+ end
214
+ end
@@ -0,0 +1,40 @@
1
+ require 'test_helper'
2
+
3
+ class TeasyTest < Minitest::Test
4
+ def teardown
5
+ Teasy.default_zone = 'UTC'
6
+ end
7
+
8
+ def test_default_zone_is_utc
9
+ assert_equal 'UTC', Teasy.default_zone
10
+ end
11
+
12
+ def test_default_zone_can_be_set
13
+ assert_equal 'UTC', Teasy.default_zone
14
+ Teasy.default_zone = 'Asia/Calcutta'
15
+ assert_equal 'Asia/Calcutta', Teasy.default_zone
16
+ end
17
+
18
+ def test_default_zone_is_thread_safe
19
+ assert_equal 'UTC', Teasy.default_zone
20
+ threads = []
21
+ threads << Thread.new do
22
+ Teasy.default_zone = 'America/New_York'
23
+ sleep 0.1
24
+ assert_equal 'America/New_York', Teasy.default_zone
25
+ end
26
+ assert_equal 'UTC', Teasy.default_zone
27
+ threads << Thread.new do
28
+ assert_equal 'UTC', Teasy.default_zone
29
+ end
30
+ threads.each(&:join)
31
+ end
32
+
33
+ def test_with_zone
34
+ assert_equal 'UTC', Teasy.default_zone
35
+ Teasy.with_zone('Europe/Berlin') do
36
+ assert_equal 'Europe/Berlin', Teasy.default_zone
37
+ end
38
+ assert_equal 'UTC', Teasy.default_zone
39
+ end
40
+ end
@@ -0,0 +1,416 @@
1
+ require 'test_helper'
2
+
3
+ class TimeWithZoneTest < Minitest::Test
4
+ def setup
5
+ @params = [2042, 4, 2, 0, 30, 45, 1.112]
6
+ @timestamptz = Teasy::TimeWithZone.new(*@params)
7
+ @timestamptz_berlin = Teasy::TimeWithZone.new(*@params, 'Europe/Berlin')
8
+ end
9
+
10
+ def test_constructor_parameter
11
+ assert_equal 2042, @timestamptz.year
12
+ assert_equal 4, @timestamptz.month
13
+ assert_equal 2, @timestamptz.day
14
+ assert_equal 0, @timestamptz.hour
15
+ assert_equal 30, @timestamptz.min
16
+ assert_equal 45, @timestamptz.sec
17
+ assert_equal 1_112, @timestamptz.nsec
18
+ end
19
+
20
+ def test_from_time
21
+ time = Time.utc(*@params)
22
+ time_with_zone = Teasy::TimeWithZone.from_time(time)
23
+ assert_instance_of Teasy::TimeWithZone, time_with_zone
24
+ assert_equal 'UTC', time_with_zone.zone
25
+ assert_equal 0, time_with_zone.hour
26
+ time_with_zone = Teasy::TimeWithZone.from_time(time, 'Europe/Berlin')
27
+ assert_equal 'Europe/Berlin', time_with_zone.zone
28
+ assert_equal 0, time_with_zone.hour
29
+ end
30
+
31
+ def test_from_utc
32
+ time = Time.utc(*@params)
33
+ time_with_zone = Teasy::TimeWithZone.from_utc(time)
34
+ assert_instance_of Teasy::TimeWithZone, time_with_zone
35
+ assert_equal 'UTC', time_with_zone.zone
36
+ assert_equal 0, time_with_zone.hour
37
+ time_with_zone = Teasy::TimeWithZone.from_utc(time, 'Europe/Berlin')
38
+ assert_equal 'Europe/Berlin', time_with_zone.zone
39
+ assert_equal 2, time_with_zone.hour
40
+ assert time_with_zone.dst?
41
+ end
42
+
43
+ def test_constructor_defaults_to_teasy_default_zone
44
+ assert_equal Teasy.default_zone, @timestamptz.zone
45
+ Teasy.stub(:default_zone, 'Europe/Berlin') do
46
+ timestamptz = Teasy::TimeWithZone.new(*@params)
47
+ assert_equal 'Europe/Berlin', timestamptz.zone
48
+ end
49
+ end
50
+
51
+ def test_constructor_applies_provided_timezone
52
+ assert_equal 'Europe/Berlin', @timestamptz_berlin.zone
53
+ end
54
+
55
+ def test_in_time_zone!
56
+ time = @timestamptz.dup.in_time_zone!('America/Chicago')
57
+ assert_instance_of Teasy::TimeWithZone, time
58
+ assert_equal @timestamptz, time
59
+ assert_equal 'America/Chicago', time.zone
60
+ assert_equal '01T19:30:45', time.strftime('%dT%H:%M:%S')
61
+ assert_equal(-18_000, time.utc_offset)
62
+ assert_equal time.object_id, time.in_time_zone!('Europe/Berlin').object_id
63
+ end
64
+
65
+ def test_in_time_zone
66
+ time = @timestamptz.in_time_zone('Asia/Calcutta')
67
+ assert_instance_of Teasy::TimeWithZone, time
68
+ assert_equal @timestamptz, time
69
+ refute_equal time.object_id, @timestamptz.in_time_zone('Asia/Calcutta')
70
+ end
71
+
72
+ def test_raises_on_ambiguous_time
73
+ dst_end = [2014, 10, 26, 2, 0, 0, 0, 'Europe/Berlin']
74
+ assert_raises(TZInfo::AmbiguousTime) do
75
+ Teasy::TimeWithZone.new(*dst_end)
76
+ end
77
+ end
78
+
79
+ def test_raises_when_period_does_not_exist
80
+ dst_start = [2014, 3, 30, 2, 30, 0, 0, 'Europe/Berlin']
81
+ assert_raises(TZInfo::PeriodNotFound) do
82
+ Teasy::TimeWithZone.new(*dst_start)
83
+ end
84
+ end
85
+
86
+ def test_addition
87
+ assert_equal 45, @timestamptz.sec
88
+ @timestamptz += 5
89
+ assert_equal 50, @timestamptz.sec
90
+ assert_instance_of Teasy::TimeWithZone, @timestamptz
91
+ end
92
+
93
+ def test_addition_around_dst_end
94
+ just_before_dst_end = [2014, 10, 26, 1, 59, 59, 0, 'Europe/Berlin']
95
+ time = Teasy::TimeWithZone.new(*just_before_dst_end)
96
+ assert((time + 3600).dst?)
97
+ assert_equal('02:59:59 +0200', (time + 3600).strftime('%H:%M:%S %z'))
98
+ refute((time + 3601).dst?)
99
+ assert_equal('02:00:00 +0100', (time + 3601).strftime('%H:%M:%S %z'))
100
+ end
101
+
102
+ def test_addition_around_dst_start
103
+ just_before_dst_start = [2014, 3, 30, 1, 59, 59, 0, 'Europe/Berlin']
104
+ time = Teasy::TimeWithZone.new(*just_before_dst_start)
105
+ refute time.dst?
106
+ assert_equal('01:59:59 +0100', time.strftime('%H:%M:%S %z'))
107
+ assert((time + 1).dst?)
108
+ assert_equal('03:00:00 +0200', (time + 1).strftime('%H:%M:%S %z'))
109
+ end
110
+
111
+ def test_subtraction
112
+ assert_equal 45, @timestamptz.sec
113
+ @timestamptz -= 5
114
+ assert_equal 40, @timestamptz.sec
115
+ assert_instance_of Teasy::TimeWithZone, @timestamptz
116
+ assert_instance_of Float, @timestamptz - @timestamptz
117
+ assert_equal 5.0, @timestamptz - (@timestamptz - 5)
118
+ end
119
+
120
+ def test_subtraction_around_dst_end
121
+ just_after_dst_end = [2014, 10, 26, 3, 0, 0, 0, 'Europe/Berlin']
122
+ time = Teasy::TimeWithZone.new(*just_after_dst_end)
123
+ refute time.dst?
124
+ refute((time - 3600).dst?)
125
+ assert_equal('02:00:00 +0100', (time - 3600).strftime('%H:%M:%S %z'))
126
+ assert((time - 3601).dst?)
127
+ assert_equal('02:59:59 +0200', (time - 3601).strftime('%H:%M:%S %z'))
128
+ end
129
+
130
+ def test_subtraction_around_dst_start
131
+ just_after_dst_start = [2014, 3, 30, 3, 0, 0, 0, 'Europe/Berlin']
132
+ time = Teasy::TimeWithZone.new(*just_after_dst_start)
133
+ assert time.dst?
134
+ assert_equal('03:00:00 +0200', time.strftime('%H:%M:%S %z'))
135
+ refute((time - 1).dst?)
136
+ assert_equal('01:59:59 +0100', (time - 1).strftime('%H:%M:%S %z'))
137
+ end
138
+
139
+ def test_comparison
140
+ assert_operator @timestamptz, :>, @timestamptz_berlin
141
+ assert_operator @timestamptz, :>=, @timestamptz_berlin
142
+ assert_operator @timestamptz_berlin, :<, @timestamptz
143
+ assert_operator @timestamptz_berlin, :<=, @timestamptz
144
+ assert_operator @timestamptz, :==, @timestamptz
145
+ @timestamptz_berlin += 7200
146
+ assert_operator @timestamptz, :==, @timestamptz_berlin
147
+ end
148
+
149
+ def test_asctime
150
+ assert_equal 'Wed Apr 2 00:30:45 2042', @timestamptz.asctime
151
+ assert_equal 'Wed Apr 2 00:30:45 2042', @timestamptz_berlin.asctime
152
+ end
153
+
154
+ def test_ctime
155
+ assert_equal 'Wed Apr 2 00:30:45 2042', @timestamptz.ctime
156
+ assert_equal 'Wed Apr 2 00:30:45 2042', @timestamptz_berlin.ctime
157
+ end
158
+
159
+ def test_day
160
+ assert_equal 2, @timestamptz.day
161
+ assert_equal 2, @timestamptz.mday
162
+ assert_equal 2, @timestamptz_berlin.day
163
+ assert_equal 2, @timestamptz_berlin.mday
164
+ end
165
+
166
+ def test_dst?
167
+ assert_equal false, @timestamptz.dst?
168
+ assert_equal true, @timestamptz_berlin.dst?
169
+ assert_equal false, (@timestamptz_berlin - 2_592_000).dst?
170
+ end
171
+
172
+ def test_eql?
173
+ assert @timestamptz.eql?(@timestamptz)
174
+ assert @timestamptz.eql?(@timestamptz_berlin + 7200)
175
+ refute @timestamptz.eql?(@timestamptz.to_time)
176
+ end
177
+
178
+ def test_friday?
179
+ friday = Teasy::TimeWithZone.new(2042, 04, 04)
180
+ friday_berlin = Teasy::TimeWithZone.new(
181
+ 2042, 04, 04, 0, 0, 0, 0, 'Europe/Berlin')
182
+ assert_equal true, friday.friday?
183
+ assert_equal true, friday_berlin.friday?
184
+ assert_equal false, @timestamptz.friday?
185
+ assert_equal false, @timestamptz_berlin.friday?
186
+ end
187
+
188
+ def test_hash
189
+ refute_equal @timestamptz.hash, @timestamptz_berlin.hash
190
+ assert_equal @timestamptz.hash, @timestamptz.dup.hash
191
+ assert_equal @timestamptz_berlin.hash, @timestamptz_berlin.utc.hash
192
+ assert_equal @timestamptz.hash, (@timestamptz_berlin + 7200).hash
193
+ refute_equal @timestamptz.hash, @timestamptz.to_time.hash
194
+ end
195
+
196
+ def test_hour
197
+ assert_equal 0, @timestamptz.hour
198
+ assert_equal 0, @timestamptz_berlin.hour
199
+ assert_equal 22, @timestamptz_berlin.utc.hour
200
+ end
201
+
202
+ def test_inspect
203
+ assert_equal '2042-04-02 00:30:45 UTC', @timestamptz.inspect
204
+ assert_equal '2042-04-02 00:30:45 +0200', @timestamptz_berlin.inspect
205
+ timestamptz = Teasy.stub(:default_zone, 'Europe/Berlin') do
206
+ Teasy::TimeWithZone.new(2042)
207
+ end
208
+ assert_equal '2042-01-01 00:00:00 +0100', timestamptz.inspect
209
+ end
210
+
211
+ def test_min
212
+ assert_equal 30, @timestamptz.min
213
+ assert_equal 31, (@timestamptz_berlin + 60).min
214
+ end
215
+
216
+ def test_month
217
+ assert_equal 4, @timestamptz.month
218
+ assert_equal 3, (@timestamptz_berlin - 100_000).month
219
+ end
220
+
221
+ def test_mon
222
+ assert_equal 4, @timestamptz.mon
223
+ assert_equal 3, (@timestamptz_berlin - 100_000).mon
224
+ end
225
+
226
+ def test_monday?
227
+ monday = Teasy::TimeWithZone.new(2042, 03, 31)
228
+ monday_berlin = Teasy::TimeWithZone.new(
229
+ 2042, 03, 31, 0, 0, 0, 0, 'Europe/Berlin')
230
+ assert_equal true, monday.monday?
231
+ assert_equal true, monday_berlin.monday?
232
+ assert_equal false, @timestamptz.monday?
233
+ assert_equal false, @timestamptz_berlin.monday?
234
+ end
235
+
236
+ def test_nsec
237
+ assert_equal 1_112, @timestamptz.nsec
238
+ assert_equal 1_112, @timestamptz_berlin.nsec
239
+ end
240
+
241
+ def test_round
242
+ assert_instance_of Teasy::TimeWithZone, @timestamptz.round
243
+ assert_instance_of Teasy::TimeWithZone, @timestamptz_berlin.round(2)
244
+ assert_equal 1_112, @timestamptz.nsec
245
+ assert_equal 0, @timestamptz.round.nsec
246
+ assert_equal 1_100, @timestamptz.round(7).nsec
247
+ assert_equal 1_112, @timestamptz.round(9).nsec
248
+ end
249
+
250
+ def test_round!
251
+ assert_equal 1_112, @timestamptz.nsec
252
+ assert_equal 1_112, @timestamptz.round!(9).nsec
253
+ assert_equal 1_110, @timestamptz.round!(8).nsec
254
+ assert_equal 1_100, @timestamptz.round!(7).nsec
255
+ assert_equal 1_000, @timestamptz.round!(6).nsec
256
+ assert_equal 0, @timestamptz.round!.nsec
257
+ assert_instance_of Teasy::TimeWithZone, @timestamptz.round!
258
+ assert_instance_of Teasy::TimeWithZone, @timestamptz_berlin.round!(2)
259
+ assert_equal @timestamptz.object_id, @timestamptz.round!.object_id
260
+ end
261
+
262
+ def test_saturday?
263
+ saturday = Teasy::TimeWithZone.new(2042, 4, 5)
264
+ saturday_berlin = Teasy::TimeWithZone.new(
265
+ 2042, 4, 5, 0, 0, 0, 0, 'Europe/Berlin')
266
+ assert_equal true, saturday.saturday?
267
+ assert_equal true, saturday_berlin.saturday?
268
+ assert_equal false, @timestamptz.saturday?
269
+ assert_equal false, @timestamptz_berlin.saturday?
270
+ end
271
+
272
+ def test_sec
273
+ assert_equal 45, @timestamptz.sec
274
+ assert_equal 45, @timestamptz_berlin.sec
275
+ assert_equal 50, (@timestamptz_berlin + 5).sec
276
+ end
277
+
278
+ def test_strftime
279
+ assert_equal '00 UTC', @timestamptz.strftime('%H %Z')
280
+ assert_equal '00 +0000', @timestamptz.strftime('%H %z')
281
+ assert_equal '00 CEST', @timestamptz_berlin.strftime('%H %Z')
282
+ assert_equal '00 +0200', @timestamptz_berlin.strftime('%H %z')
283
+ end
284
+
285
+ def test_subsec
286
+ assert_equal 1.112.to_r / 1_000_000, @timestamptz.subsec
287
+ assert_equal 1.112.to_r / 1_000_000, @timestamptz_berlin.subsec
288
+ end
289
+
290
+ def test_sunday?
291
+ sunday = Teasy::TimeWithZone.new(2042, 4, 6)
292
+ sunday_berlin = Teasy::TimeWithZone.new(
293
+ 2042, 4, 6, 0, 0, 0, 0, 'Europe/Berlin')
294
+ assert_equal true, sunday.sunday?
295
+ assert_equal true, sunday_berlin.sunday?
296
+ assert_equal false, @timestamptz.sunday?
297
+ assert_equal false, @timestamptz_berlin.sunday?
298
+ end
299
+
300
+ def test_thursday?
301
+ thursday = Teasy::TimeWithZone.new(2042, 4, 3)
302
+ thursday_berlin = Teasy::TimeWithZone.new(
303
+ 2042, 4, 3, 0, 0, 0, 0, 'Europe/Berlin')
304
+ assert_equal true, thursday.thursday?
305
+ assert_equal true, thursday_berlin.thursday?
306
+ assert_equal false, @timestamptz.thursday?
307
+ assert_equal false, @timestamptz_berlin.thursday?
308
+ end
309
+
310
+ def test_to_a
311
+ assert_equal [45, 30, 0, 2, 4, 2042, 3, 92, false, 'UTC'], @timestamptz.to_a
312
+ berlin_to_a = @timestamptz_berlin.to_a
313
+ assert_equal [45, 30, 0, 2, 4, 2042, 3, 92, true, 'CEST'], berlin_to_a
314
+ end
315
+
316
+ def test_to_f
317
+ assert_instance_of Float, @timestamptz.to_f
318
+ assert_in_epsilon 2_280_011_445.000_001, @timestamptz.to_f
319
+ assert_in_epsilon 2_280_004_245.000_001, @timestamptz_berlin.to_f
320
+ end
321
+
322
+ def test_to_i
323
+ assert_instance_of Fixnum, @timestamptz.to_i
324
+ assert_equal 2_280_011_445, @timestamptz.to_i
325
+ assert_equal 2_280_004_245, @timestamptz_berlin.to_i
326
+ end
327
+
328
+ def test_to_r
329
+ assert_instance_of Rational, @timestamptz.to_r
330
+ assert_equal 2_272_147_200.to_r, Teasy::TimeWithZone.new(2042).to_r
331
+ time_with_zone = Teasy::TimeWithZone.new(
332
+ 2042, 1, 1, 1, 0, 0, 0, 'Europe/Berlin')
333
+ assert_equal 2_272_147_200.to_r, time_with_zone.to_r
334
+ end
335
+
336
+ def test_to_s
337
+ assert_equal '2042-04-02 00:30:45 UTC', @timestamptz.to_s
338
+ assert_equal '2042-04-02 00:30:45 +0200', @timestamptz_berlin.to_s
339
+ timestamptz = Teasy.stub(:default_zone, 'Europe/Berlin') do
340
+ Teasy::TimeWithZone.new(2042)
341
+ end
342
+ assert_equal '2042-01-01 00:00:00 +0100', timestamptz.to_s
343
+ end
344
+
345
+ def test_tuesday?
346
+ tuesday = Teasy::TimeWithZone.new(2042, 4, 1)
347
+ tuesday_berlin = Teasy::TimeWithZone.new(
348
+ 2042, 4, 1, 0, 0, 0, 0, 'Europe/Berlin')
349
+ assert_equal true, tuesday.tuesday?
350
+ assert_equal true, tuesday_berlin.tuesday?
351
+ assert_equal false, @timestamptz.tuesday?
352
+ assert_equal false, @timestamptz_berlin.tuesday?
353
+ end
354
+
355
+ def test_usec
356
+ assert_equal 1, @timestamptz.usec
357
+ assert_equal 1, @timestamptz_berlin.usec
358
+ end
359
+
360
+ def test_utc
361
+ assert_instance_of Teasy::TimeWithZone, @timestamptz.utc
362
+ assert_instance_of Teasy::TimeWithZone, @timestamptz_berlin.utc
363
+ assert_equal @timestamptz, @timestamptz.utc
364
+ assert_equal @timestamptz_berlin, @timestamptz_berlin.utc
365
+ assert @timestamptz_berlin.utc.utc?
366
+ refute_equal @timestamptz.object_id, @timestamptz.utc.object_id
367
+ end
368
+
369
+ def test_utc!
370
+ timestamptz = @timestamptz.dup.utc!
371
+ timestamptz_berlin = @timestamptz_berlin.dup.utc!
372
+ assert_instance_of Teasy::TimeWithZone, timestamptz
373
+ assert_instance_of Teasy::TimeWithZone, timestamptz_berlin
374
+ assert_equal @timestamptz, timestamptz
375
+ assert_equal @timestamptz_berlin, timestamptz_berlin
376
+ assert timestamptz_berlin.utc?
377
+ assert_equal timestamptz.object_id, timestamptz.utc!.object_id
378
+ end
379
+
380
+ def test_utc?
381
+ assert @timestamptz.utc?
382
+ refute @timestamptz_berlin.utc?
383
+ end
384
+
385
+ def test_utc_offset
386
+ assert_equal 0, @timestamptz.utc_offset
387
+ assert_equal 7200, @timestamptz_berlin.utc_offset
388
+ end
389
+
390
+ def test_wday
391
+ assert_equal 3, @timestamptz.wday
392
+ assert_equal 3, @timestamptz_berlin.wday
393
+ end
394
+
395
+ def test_wednesday?
396
+ assert_equal true, @timestamptz.wednesday?
397
+ assert_equal true, @timestamptz_berlin.wednesday?
398
+ assert_equal false, (@timestamptz + 86_400).wednesday?
399
+ assert_equal false, (@timestamptz_berlin + 86_400).wednesday?
400
+ end
401
+
402
+ def test_yday
403
+ assert_equal 92, @timestamptz.yday
404
+ assert_equal 92, @timestamptz_berlin.yday
405
+ end
406
+
407
+ def test_year
408
+ assert_equal 2042, @timestamptz.year
409
+ assert_equal 2042, @timestamptz_berlin.year
410
+ end
411
+
412
+ def test_zone
413
+ assert_equal 'UTC', @timestamptz.zone
414
+ assert_equal 'Europe/Berlin', @timestamptz_berlin.zone
415
+ end
416
+ end
@@ -0,0 +1,6 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/reporters'
3
+
4
+ Minitest::Reporters.use!
5
+
6
+ require 'teasy'
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teasy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kai Kuchenbecker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tzinfo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tzinfo-data
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2015.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2015.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: "Teasy builds on tzinfo to get time zone data and\n provides
112
+ time classes to ease working with time zones.\n It provides
113
+ TimeWithZone which is similiar to Rails'\n ActiveSupport::TimeWithZone
114
+ but with less quirks. And\n it provides FloatingTime which
115
+ is time without a zone.\n "
116
+ email:
117
+ - Kai.Kuchenbecker@invision.de
118
+ executables: []
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - ".gitignore"
123
+ - ".rubocop.yml"
124
+ - Gemfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - lib/teasy.rb
129
+ - lib/teasy/floating_time.rb
130
+ - lib/teasy/time_with_zone.rb
131
+ - lib/teasy/version.rb
132
+ - teasy.gemspec
133
+ - test/teasy/floating_time_test.rb
134
+ - test/teasy/teasy_test.rb
135
+ - test/teasy/time_with_zone_test.rb
136
+ - test/test_helper.rb
137
+ homepage: ''
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.4.5
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Teasy intends to make handling time zones easy.
161
+ test_files:
162
+ - test/teasy/floating_time_test.rb
163
+ - test/teasy/teasy_test.rb
164
+ - test/teasy/time_with_zone_test.rb
165
+ - test/test_helper.rb