et-orbi 1.1.3 → 1.1.4

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/CREDITS.md +1 -0
  4. data/lib/et-orbi.rb +40 -4
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6330469df07c1668e684b3b17a7413f58b206791
4
- data.tar.gz: a8b053546f08ca127a8cf99d71e7b2ff9119687c
3
+ metadata.gz: d8ef8fc834961c17b876b47c41d4d68c7901aa84
4
+ data.tar.gz: 6f2be70aa989f8a1245556b59bfefba5bd21e9cd
5
5
  SHA512:
6
- metadata.gz: 343aa588d3a9fb2cb36ca7ac303797c23d27e5a2dca4d5db640898481d5fe275f63f363ef3b97aa492fe28aa1d2e0e58ed4f134bfb949f8c76d9b2e2e6d6c479
7
- data.tar.gz: 4b852a4a9ba6aaa55687220511d0df6a37898560cb218dda54ec5f2f3e35ec4fcd4e4a9512624c1c80a574927c9b19d37ea0f71709727ed35a117f36c644e528
6
+ metadata.gz: 92da61eef8752d71237a83a14d8295c818f4236ecc725616bb7264ba6c0ff019fafabc813912e3bcb9e24b408da37d5222658b8671223a91cba9aa48867cdf52
7
+ data.tar.gz: c79094b2d43fa66d2907552603c8e973a0936e8a1b5d73d0b55c6d505eef6e280c8c868cbaa011119a9669abe1bc3314fe476de377806d780187fe277fba0b79
@@ -2,6 +2,12 @@
2
2
  # et-orbi CHANGELOG.md
3
3
 
4
4
 
5
+ ## et-orbi 1.1.4 released 2018-07-25
6
+
7
+ - Silence 3 Ruby warnings (thanks Jamie Stackhouse, gh-13)
8
+ - Introduce EtOrbi::Eotime.reach(points)
9
+
10
+
5
11
  ## et-orbi 1.1.3 released 2018-07-14
6
12
 
7
13
  - Introduce EtOrbi::EoTime#ambiguous?
data/CREDITS.md CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  # et-orbi credits
3
3
 
4
+ * Jamie Stackhouse https://github.com/itsjamie reported warnings, gh-13
4
5
  * mlotfi2005 https://github.com/mlotfi2005 reported infinite loop, gh-12
5
6
  * Mayur Dave https://github.com/mdave16 reported trailing warning, gh-10
6
7
  * Phil Ross https://github.com/philr added support for upcoming TZInfo 2.x, gh-9
@@ -9,7 +9,7 @@ require 'et-orbi/zone_aliases'
9
9
 
10
10
  module EtOrbi
11
11
 
12
- VERSION = '1.1.3'
12
+ VERSION = '1.1.4'
13
13
 
14
14
  #
15
15
  # module methods
@@ -343,7 +343,7 @@ module EtOrbi
343
343
 
344
344
  false
345
345
 
346
- rescue TZInfo::AmbiguousTime => e
346
+ rescue TZInfo::AmbiguousTime
347
347
 
348
348
  true
349
349
  end
@@ -541,6 +541,38 @@ module EtOrbi
541
541
  [ count_weeks(-1), - count_weeks(1) ]
542
542
  end
543
543
 
544
+ def reach(points)
545
+
546
+ t = EoTime.new(self.to_f, @zone)
547
+ step = 1
548
+
549
+ s = points[:second] || points[:sec] || points[:s]
550
+ m = points[:minute] || points[:min] || points[:m]
551
+ h = points[:hour] || points[:hou] || points[:h]
552
+
553
+ fail ArgumentError.new("missing :second, :minute, and :hour") \
554
+ unless s || m || h
555
+
556
+ if !s && !m
557
+ step = 60 * 60
558
+ t -= t.sec
559
+ t -= t.min * 60
560
+ elsif !s
561
+ step = 60
562
+ t -= t.sec
563
+ end
564
+
565
+ loop do
566
+ t += step
567
+ next if s && t.sec != s
568
+ next if m && t.min != m
569
+ next if h && t.hour != h
570
+ break
571
+ end
572
+
573
+ t
574
+ end
575
+
544
576
  protected
545
577
 
546
578
  # Returns a Ruby Time instance.
@@ -672,7 +704,8 @@ module EtOrbi
672
704
 
673
705
  def os_tz
674
706
 
675
- return (@_os_zone == '' ? nil : @_os_zone) if @_os_zone
707
+ return (@_os_zone == '' ? nil : @_os_zone) \
708
+ if defined?(@_os_zone) && @_os_zone
676
709
 
677
710
  @os_tz ||= (debian_tz || centos_tz || osx_tz)
678
711
  end
@@ -707,7 +740,10 @@ module EtOrbi
707
740
  i = n.to_i
708
741
  sn = i < 0 ? '-' : '+'; i = i.abs
709
742
  hr = i / 3600; mn = i % 3600; sc = i % 60
710
- (sc > 0 ? "%s%02d:%02d:%02d" : "%s%02d:%02d") % [ sn, hr, mn, sc ]
743
+
744
+ sc > 0 ?
745
+ '%s%02d:%02d:%02d' % [ sn, hr, mn, sc ] :
746
+ '%s%02d:%02d' % [ sn, hr, mn ]
711
747
  end
712
748
 
713
749
  def get_offset_tzone(str)
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.3
4
+ version: 1.1.4
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-07-14 00:00:00.000000000 Z
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.5.2
78
+ rubygems_version: 2.5.2.3
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: time with zones