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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/tz_offset/version.rb +1 -1
- data/lib/tz_offset.rb +25 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6caf2eb01f0a29365f5fa0e7b590a2fc6578d7d8
|
4
|
+
data.tar.gz: bd8383c6df9c377fd99e0abdd20bf35dfb4d49e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83943865999ffb0dd7df78ae68cc9eb5fd9ed2337e0bbb71de722edead758a1f337507cabe205891122a833e1bb2ad405009bce172067a4eeb903efe1da31d2c
|
7
|
+
data.tar.gz: 723be526b08eb9ab0a4479115357540207648bf8de5a6d3aa6b869c25e32965175efb50c62f7ddcd24a8c708ffd8d513f0d343c0000b13b0f2ea9e5bf1187fa9
|
data/CHANGELOG.md
ADDED
data/lib/tz_offset/version.rb
CHANGED
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.
|
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-
|
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.
|
188
|
+
rubygems_version: 2.4.8
|
188
189
|
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: Simple and solid timezone offset class
|