et-orbi 1.0.6 → 1.0.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/et-orbi.rb +25 -17
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16693871e0e1a8330e6ecade907b21302ad124ab
4
- data.tar.gz: 00fee3dbf2143ee21043597a1d64f7d19c2c6dfa
3
+ metadata.gz: 5a73f3948e76c89fdb79154e903e590594eadee8
4
+ data.tar.gz: '068a020b01766dad22cad3e2b0f3d20a612ceaaf'
5
5
  SHA512:
6
- metadata.gz: 6f151d68c6c1f070945f9cf9718e7d38004117832b53acac741de0e5e2c38ec8cd06c4bccca60a93072bc1b7dad2342a6e5bac7ed17f2a8829ec47554e36e0be
7
- data.tar.gz: 66af905287bb713bc376adb0e67b7c1eac19a486fbc4a93c902615f33280dad69586f245726e3fb19a57ac6ab5649a7737391d3b1ead3d13b7aef6a945f96e65
6
+ metadata.gz: 256b38da4dd9788c36d6499ff06e29915f5ee80413112a7bf5a9d5b678ac1b6a9fc520de4d5234a34c727adde6e5e0fe02cf815b37927d839e87271eda46ed66
7
+ data.tar.gz: fe1b1a1bf20569bfe2a2c96d94bd3b9ed32c75a3df400622fef34d907ac20b4c154d055f4e3a991171655e685b40b3c84cc2b2687634bba28d6583c65312a54b
@@ -2,6 +2,12 @@
2
2
  # et-orbi CHANGELOG.md
3
3
 
4
4
 
5
+ ## et-orbi 1.0.7 released 2017-10-07
6
+
7
+ - Leverage ActiveSupport::TimeWithZone when present, gh-6
8
+ - Start error messages with a capital
9
+
10
+
5
11
  ## et-orbi 1.0.6 released 2017-10-05
6
12
 
7
13
  - Introduce `make info`
@@ -7,7 +7,7 @@ require 'tzinfo'
7
7
 
8
8
  module EtOrbi
9
9
 
10
- VERSION = '1.0.6'
10
+ VERSION = '1.0.7'
11
11
 
12
12
  #
13
13
  # module methods
@@ -30,7 +30,7 @@ module EtOrbi
30
30
  begin
31
31
  DateTime.parse(str)
32
32
  rescue
33
- fail ArgumentError, "no time information in #{str.inspect}"
33
+ fail ArgumentError, "No time information in #{str.inspect}"
34
34
  end #if rold
35
35
  #
36
36
  # is necessary since Time.parse('xxx') in Ruby < 1.9 yields `now`
@@ -87,7 +87,7 @@ module EtOrbi
87
87
  when Numeric then make_from_numeric(o, zone)
88
88
  when ::EtOrbi::EoTime then make_from_eotime(o, zone)
89
89
  else fail ArgumentError.new(
90
- "cannot turn #{o.inspect} to a ::EtOrbi::EoTime instance")
90
+ "Cannot turn #{o.inspect} to a ::EtOrbi::EoTime instance")
91
91
  end
92
92
  end
93
93
 
@@ -95,6 +95,7 @@ module EtOrbi
95
95
 
96
96
  z =
97
97
  zone ||
98
+ get_as_tzone(t) ||
98
99
  get_tzone(t.zone) ||
99
100
  get_local_tzone(t)
100
101
 
@@ -218,21 +219,28 @@ module EtOrbi
218
219
 
219
220
  def get_local_tzone(t)
220
221
 
221
- # lt = local_tzone
222
- # lp = lt.period_for_local(t)
223
- # ab = lp.abbreviation.to_s
224
- #
225
- # return lt \
226
- # if ab == t.zone
227
- # return lt \
228
- # if ab.match(/\A[-+]\d{2}(:?\d{2})?\z/) && lp.utc_offset == t.utc_offset
229
- #
230
- # nil
222
+ #lt = local_tzone
223
+ #lp = lt.period_for_local(t)
224
+ #ab = lp.abbreviation.to_s
225
+ #
226
+ #return lt \
227
+ # if ab == t.zone
228
+ #return lt \
229
+ # if ab.match(/\A[-+]\d{2}(:?\d{2})?\z/) && lp.utc_offset == t.utc_offset
230
+ #
231
+ #nil
232
+ #
233
+ # keep that in the fridge for now
231
234
 
232
235
  l = Time.local(t.year, t.month, t.day, t.hour, t.min, t.sec, t.usec)
233
236
 
234
237
  t.zone == l.zone ? local_tzone : nil
235
238
  end
239
+
240
+ def get_as_tzone(t)
241
+
242
+ t.respond_to?(:time_zone) ? t.time_zone : nil
243
+ end
236
244
  end
237
245
 
238
246
  # Our EoTime class (which quacks like a ::Time).
@@ -294,7 +302,7 @@ module EtOrbi
294
302
  @zone = self.class.get_tzone(zone || :local)
295
303
 
296
304
  fail ArgumentError.new(
297
- "cannot determine timezone from #{zone.inspect}" +
305
+ "Cannot determine timezone from #{zone.inspect}" +
298
306
  "\n#{EtOrbi.render_nozone_time(s)}" +
299
307
  "\n#{EtOrbi.platform_info.sub(',debian:', ",\ndebian:")}" +
300
308
  "\nTry setting `ENV['TZ'] = 'Continent/City'` in your script " +
@@ -479,11 +487,11 @@ module EtOrbi
479
487
  nt
480
488
  when ::Time, ::EtOrbi::EoTime
481
489
  fail ArgumentError.new(
482
- "cannot add #{t.class} to EoTime") if dir > 0
490
+ "Cannot add #{t.class} to EoTime") if dir > 0
483
491
  @seconds + dir * t.to_f
484
492
  else
485
493
  fail ArgumentError.new(
486
- "cannot call add or subtract #{t.class} to EoTime instance")
494
+ "Cannot call add or subtract #{t.class} to EoTime instance")
487
495
  end
488
496
  end
489
497
 
@@ -550,7 +558,7 @@ module EtOrbi
550
558
  def _to_f(o)
551
559
 
552
560
  fail ArgumentError(
553
- "comparison of EoTime with #{o.inspect} failed"
561
+ "Comparison of EoTime with #{o.inspect} failed"
554
562
  ) unless o.is_a?(EoTime) || o.is_a?(Time)
555
563
 
556
564
  o.to_f
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.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo