tz_offset 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: f9363efb498a8b6180965d24800702afb397ce68
4
- data.tar.gz: 50c57cf3be860d0f7e8674b7499a8aec964c552f
3
+ metadata.gz: 6caf2eb01f0a29365f5fa0e7b590a2fc6578d7d8
4
+ data.tar.gz: bd8383c6df9c377fd99e0abdd20bf35dfb4d49e2
5
5
  SHA512:
6
- metadata.gz: 31dbb1f263b893d1299772afcaadb0e7e87e90565ff35c91af64482946f81f5737ebef7274520dba33eb601847e7f4274a0bb4088fea979befab07cf5bece8f5
7
- data.tar.gz: dc8e375a8e93506c02ad56c95d91d365059564add20ab516568c9ef50cdc831a2d31e470b3e2357c77ea6c9c072a3b1e690600ec4432b37dc73cc752446ee7d4
6
+ metadata.gz: 83943865999ffb0dd7df78ae68cc9eb5fd9ed2337e0bbb71de722edead758a1f337507cabe205891122a833e1bb2ad405009bce172067a4eeb903efe1da31d2c
7
+ data.tar.gz: 723be526b08eb9ab0a4479115357540207648bf8de5a6d3aa6b869c25e32965175efb50c62f7ddcd24a8c708ffd8d513f0d343c0000b13b0f2ea9e5bf1187fa9
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ TZOffset Changelog
2
+ ==================
3
+
4
+ 0.0.2 - 2016-10-25
5
+ ------------------
6
+
7
+ * Add `TZOffset#parse`.
@@ -1,3 +1,3 @@
1
1
  class TZOffset
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
data/lib/tz_offset.rb CHANGED
@@ -162,6 +162,31 @@ class TZOffset
162
162
  ABBREV.values.flatten.detect { |tz| tz.region == region && tz.dst? == !dst? }
163
163
  end
164
164
 
165
+ # Like `Time.parse`, but produces time in current offset.
166
+ #
167
+ # @note
168
+ # If time string contains timezone abbreviation or offset by itself, it is just ignored.
169
+ # The method is intended for "quick-n-dirty" parsing of things like "what is 12:30 in
170
+ # CEST currently?"
171
+ #
172
+ # @example
173
+ # # My current date and zone
174
+ # Time.parse('12:30')
175
+ # # => 2016-10-26 12:30:00 +0300
176
+ # TZOffset.parse('PDT').parse('12:30')
177
+ # # => 2016-10-26 12:30:00 -0700
178
+ # # Now I can know what it will be for me when somebody
179
+ # # says "I'll be available 12:30 PDT tomorrow":
180
+ # TZOffset.parse('PDT').parse('12:30').localtime
181
+ # # => 2016-10-26 22:30:00 +0300
182
+ #
183
+ # @param str [String] Same string that `Time.parse` could accept.
184
+ # @return [Time] Time parsed from `str` into current offset.
185
+ def parse(str)
186
+ t = Time.parse(str)
187
+ t && local(t.year, t.month, t.day, t.hour, t.min, t.sec)
188
+ end
189
+
165
190
  private
166
191
 
167
192
  def sign
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tz_offset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -157,6 +157,7 @@ extensions: []
157
157
  extra_rdoc_files: []
158
158
  files:
159
159
  - ".yardopts"
160
+ - CHANGELOG.md
160
161
  - README.md
161
162
  - lib/tz_offset.rb
162
163
  - lib/tz_offset/abbrev.rb
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
185
  version: '0'
185
186
  requirements: []
186
187
  rubyforge_project:
187
- rubygems_version: 2.5.1
188
+ rubygems_version: 2.4.8
188
189
  signing_key:
189
190
  specification_version: 4
190
191
  summary: Simple and solid timezone offset class