et-orbi 1.1.0 → 1.1.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Makefile +1 -0
- data/lib/et-orbi.rb +24 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db2e44b25fa9806ddea412a4c4ab67f404f8abf7
|
4
|
+
data.tar.gz: 28bff7ef341b1458b17a604638878f17c131ad76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0411908916cd638a834b73d73685c3615154c26b39d1ef264bb0e924808bbb845dab0ee7d89c12a2d0fc20757e748a0dc2b1785c12396a754123a65393cb7b5c'
|
7
|
+
data.tar.gz: bde96903887538a4f15885e74996882c68d662d6692e76f217fe471782ef9b8951df0aee97b0c6150ab0ffd5e6985579f9786f00b6e5c4b059b341eb4235b904
|
data/CHANGELOG.md
CHANGED
data/Makefile
CHANGED
@@ -8,6 +8,7 @@ VERSION = \
|
|
8
8
|
|
9
9
|
count_lines:
|
10
10
|
find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
|
11
|
+
find spec -name "*_spec.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
|
11
12
|
cl: count_lines
|
12
13
|
|
13
14
|
gemspec_validate:
|
data/lib/et-orbi.rb
CHANGED
@@ -7,7 +7,7 @@ require 'tzinfo'
|
|
7
7
|
|
8
8
|
module EtOrbi
|
9
9
|
|
10
|
-
VERSION = '1.1.
|
10
|
+
VERSION = '1.1.1'
|
11
11
|
|
12
12
|
#
|
13
13
|
# module methods
|
@@ -47,7 +47,7 @@ module EtOrbi
|
|
47
47
|
opts[:zone] ||
|
48
48
|
str_zone ||
|
49
49
|
find_olson_zone(str) ||
|
50
|
-
|
50
|
+
determine_local_tzone
|
51
51
|
#p [ :parse, :zone, zone ]
|
52
52
|
|
53
53
|
str = str.sub(zone.name, '') unless zone.name.match(/\A[-+]/)
|
@@ -143,7 +143,7 @@ module EtOrbi
|
|
143
143
|
|
144
144
|
return o if o.is_a?(::TZInfo::Timezone)
|
145
145
|
return nil if o == nil
|
146
|
-
return
|
146
|
+
return determine_local_tzone if o == :local
|
147
147
|
return ::TZInfo::Timezone.get('Zulu') if o == 'Z'
|
148
148
|
return o.tzinfo if o.respond_to?(:tzinfo)
|
149
149
|
|
@@ -156,24 +156,6 @@ module EtOrbi
|
|
156
156
|
(::TZInfo::Timezone.get(o) rescue nil)
|
157
157
|
end
|
158
158
|
|
159
|
-
def local_tzone
|
160
|
-
|
161
|
-
@local_tzone_tz ||= nil
|
162
|
-
@local_tzone_loaded_at ||= nil
|
163
|
-
|
164
|
-
@local_tzone = nil \
|
165
|
-
if @local_tzone_loaded_at && (Time.now > @local_tzone_loaded_at + 1800)
|
166
|
-
@local_tzone = nil \
|
167
|
-
if @local_tzone_tz != ENV['TZ']
|
168
|
-
|
169
|
-
@local_tzone ||=
|
170
|
-
begin
|
171
|
-
@local_tzone_tz = ENV['TZ']
|
172
|
-
@local_tzone_loaded_at = Time.now
|
173
|
-
determine_local_tzone
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
159
|
def render_nozone_time(seconds)
|
178
160
|
|
179
161
|
t =
|
@@ -181,10 +163,10 @@ module EtOrbi
|
|
181
163
|
ts =
|
182
164
|
t.strftime('%Y-%m-%d %H:%M:%S') +
|
183
165
|
".#{(seconds % 1).to_s.split('.').last}"
|
166
|
+
tz =
|
167
|
+
EtOrbi.determine_local_tzone
|
184
168
|
z =
|
185
|
-
|
186
|
-
EtOrbi.local_tzone.period_for_local(t).abbreviation.to_s :
|
187
|
-
nil
|
169
|
+
tz ? tz.period_for_local(t).abbreviation.to_s : nil
|
188
170
|
|
189
171
|
"(secs:#{seconds},utc~:#{ts.inspect},ltz~:#{z.inspect})"
|
190
172
|
end
|
@@ -200,9 +182,12 @@ module EtOrbi
|
|
200
182
|
'tzid' => defined?(TZInfo::Data),
|
201
183
|
'rv' => RUBY_VERSION,
|
202
184
|
'rp' => RUBY_PLATFORM,
|
203
|
-
'eov' => EtOrbi::VERSION,
|
204
185
|
'rorv' => (Rails::VERSION::STRING rescue nil),
|
205
186
|
'astz' => ([ Time.zone.class, Time.zone.tzinfo.name ] rescue nil),
|
187
|
+
'eov' => EtOrbi::VERSION,
|
188
|
+
'eotnz' => EtOrbi::EoTime.now.zone,
|
189
|
+
'eotnfz' => EtOrbi::EoTime.now.strftime('%z'),
|
190
|
+
'eotlzn' => EtOrbi::EoTime.local_tzone.name,
|
206
191
|
}.collect(&etos).join(',') + ',' +
|
207
192
|
gather_tzs.collect(&etos).join(',') +
|
208
193
|
')'
|
@@ -237,7 +222,7 @@ module EtOrbi
|
|
237
222
|
|
238
223
|
l = Time.local(t.year, t.month, t.day, t.hour, t.min, t.sec, t.usec)
|
239
224
|
|
240
|
-
t.zone == l.zone ?
|
225
|
+
(t.zone == l.zone) ? determine_local_tzone : nil
|
241
226
|
end
|
242
227
|
|
243
228
|
def get_as_tzone(t)
|
@@ -279,7 +264,7 @@ module EtOrbi
|
|
279
264
|
|
280
265
|
def local_tzone
|
281
266
|
|
282
|
-
EtOrbi.
|
267
|
+
EtOrbi.determine_local_tzone
|
283
268
|
end
|
284
269
|
|
285
270
|
def platform_info
|
@@ -299,7 +284,7 @@ module EtOrbi
|
|
299
284
|
|
300
285
|
def local(*a)
|
301
286
|
|
302
|
-
EtOrbi.make_from_array(a,
|
287
|
+
EtOrbi.make_from_array(a, local_tzone)
|
303
288
|
end
|
304
289
|
end
|
305
290
|
|
@@ -648,7 +633,7 @@ module EtOrbi
|
|
648
633
|
|
649
634
|
def os_tz
|
650
635
|
|
651
|
-
debian_tz || centos_tz || osx_tz
|
636
|
+
@os_tz ||= (debian_tz || centos_tz || osx_tz)
|
652
637
|
end
|
653
638
|
|
654
639
|
#
|
@@ -704,7 +689,6 @@ module EtOrbi
|
|
704
689
|
tzi.offset(id, utc_off, 0, id)
|
705
690
|
tzi.create_timezone
|
706
691
|
end
|
707
|
-
|
708
692
|
end
|
709
693
|
|
710
694
|
def determine_local_tzones
|
@@ -713,6 +697,7 @@ module EtOrbi
|
|
713
697
|
.collect { |i| (Time.now + i * 30 * 24 * 3600).zone }
|
714
698
|
.uniq
|
715
699
|
.sort
|
700
|
+
.join('|')
|
716
701
|
|
717
702
|
t = Time.now
|
718
703
|
#tu = t.dup.utc # /!\ dup is necessary, #utc modifies its target
|
@@ -720,16 +705,16 @@ module EtOrbi
|
|
720
705
|
twin = Time.utc(t.year, 1, 1) # winter
|
721
706
|
tsum = Time.utc(t.year, 7, 1) # summer
|
722
707
|
|
723
|
-
::TZInfo::Timezone.all
|
724
|
-
|
725
|
-
pabbs =
|
726
|
-
[
|
727
|
-
tz.period_for_utc(twin).abbreviation.to_s,
|
728
|
-
tz.period_for_utc(tsum).abbreviation.to_s
|
729
|
-
].uniq.sort
|
708
|
+
@tz_all ||= ::TZInfo::Timezone.all
|
709
|
+
@tz_winter_summer ||= {}
|
730
710
|
|
731
|
-
|
732
|
-
|
711
|
+
@tz_winter_summer[tabbs] ||= @tz_all
|
712
|
+
.select { |tz|
|
713
|
+
tabbs ==
|
714
|
+
[
|
715
|
+
tz.period_for_utc(twin).abbreviation.to_s,
|
716
|
+
tz.period_for_utc(tsum).abbreviation.to_s
|
717
|
+
].uniq.sort.join('|') }
|
733
718
|
end
|
734
719
|
|
735
720
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: et-orbi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|