et-orbi 1.0.8 → 1.0.9

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 (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/CREDITS.md +4 -0
  4. data/LICENSE.txt +1 -1
  5. data/lib/et-orbi.rb +39 -22
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d6a8309df165816b992a3cf023e2402ee99fd43
4
- data.tar.gz: 18054a7b9d63665fd8bec081125a813256d900ea
3
+ metadata.gz: 5c44c3ff9dc84f7dd7e87950a02dfcb9496a390a
4
+ data.tar.gz: 4c2ecd717ff29139f3689372368208cf9da040bf
5
5
  SHA512:
6
- metadata.gz: 494279c96db53e01a9b7aabc72de4acaca3ae5be35695532c93f9d5cce3515d3ce6aece9de6cde1e3ff545f9ab6dcf86638a5c43ac20358b0f255a6a527c9db5
7
- data.tar.gz: bebb4a2a3d67cfca571a67f5875c3ea877fd21a23b643730910880ca5c4a2877caa67c562b38d5bffa6dc8c60b71d4652f8aaa2e7d049b595ce3828f8db92993
6
+ metadata.gz: 58b50b5355dc89c6314b71a2b14bfd294a67ef4cc000bb500af3000e48e2b6741c8cf99e9509511920ee79870d4c36afe15677b9d7022d0cd5e816f6d61a56b6
7
+ data.tar.gz: 6e2e3aac93b0d0eefee5dd833e932b60235e18c4ef98355d9859950717d50891fddb5fe5e220c27c2728897de8fa923a8abaedefdb7b0082bbcfbc93cfef0675
@@ -2,6 +2,13 @@
2
2
  # et-orbi CHANGELOG.md
3
3
 
4
4
 
5
+ ## et-orbi 1.0.9 released 2018-01-19
6
+
7
+ - Silence EoTime#strfz warning
8
+ - Silence warnings reported by @mdave16, gh-10
9
+ - @philr added support for upcoming tzinfo 2.x, gh-9
10
+
11
+
5
12
  ## et-orbi 1.0.8 released 2017-10-24
6
13
 
7
14
  - Ensure ::EoTime.new accepts ActiveSupport::TimeZone, closes gh-8
data/CREDITS.md CHANGED
@@ -1,10 +1,14 @@
1
1
 
2
2
  # et-orbi credits
3
3
 
4
+ * Mayur Dave https://github.com/mdave16 reported trailing warning, gh-10
5
+ * Phil Ross https://github.com/philr added support for upcoming TZInfo 2.x, gh-9
4
6
  * Miles Lane https://github.com/mileslane issue with ActiveSupport::TimeZone, gh-8
5
7
  * Chris Arcand https://github.com/chrisarcand shew various issues around America/Chicago on OSX, gh-4
6
8
  * Jeremy Strouse https://github.com/jstrouse helped alleviate issue with older versions of TZInfo
7
9
 
10
+ See also https://github.com/floraison/et-orbi/graphs/contributors
11
+
8
12
 
9
13
  ## since rufus-scheduler
10
14
 
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2017-2017, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2017-2018, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -7,7 +7,7 @@ require 'tzinfo'
7
7
 
8
8
  module EtOrbi
9
9
 
10
- VERSION = '1.0.8'
10
+ VERSION = '1.0.9'
11
11
 
12
12
  #
13
13
  # module methods
@@ -62,7 +62,7 @@ module EtOrbi
62
62
  if str_zone
63
63
  local.to_f
64
64
  else
65
- zone.period_for_local(local).to_utc(local).to_f
65
+ zone.local_to_utc(local).to_f
66
66
  end
67
67
  #p [ :parse, :secs, secs ]
68
68
 
@@ -125,7 +125,6 @@ module EtOrbi
125
125
 
126
126
  def make_from_string(s, zone)
127
127
 
128
- #p [ :mfs, s, zone ]
129
128
  parse(s, zone: zone)
130
129
  end
131
130
 
@@ -159,6 +158,9 @@ module EtOrbi
159
158
 
160
159
  def local_tzone
161
160
 
161
+ @local_tzone_tz ||= nil
162
+ @local_tzone_loaded_at ||= nil
163
+
162
164
  @local_tzone = nil \
163
165
  if @local_tzone_loaded_at && (Time.now > @local_tzone_loaded_at + 1800)
164
166
  @local_tzone = nil \
@@ -510,11 +512,12 @@ module EtOrbi
510
512
 
511
513
  # Returns a Ruby Time instance.
512
514
  #
513
- # Warning: the timezone of that Time instance will be UTC.
515
+ # Warning: the timezone of that Time instance will be UTC when used with
516
+ # TZInfo < 2.0.0.
514
517
  #
515
518
  def to_time
516
519
 
517
- @time ||= begin; u = utc; @zone.period_for_utc(u).to_local(u); end
520
+ @time ||= begin; u = utc; @zone.utc_to_local(u); end
518
521
  end
519
522
 
520
523
  def count_weeks(dir)
@@ -544,16 +547,13 @@ module EtOrbi
544
547
  mn = (off % 3600) / 60
545
548
  sc = 0
546
549
 
547
- fmt =
548
- if code == '%z'
549
- "%s%02d%02d"
550
- elsif code == '%:z'
551
- "%s%02d:%02d"
552
- else
553
- "%s%02d:%02d:%02d"
554
- end
555
-
556
- fmt % [ sn, hr, mn, sc ]
550
+ if code == '%z'
551
+ '%s%02d%02d' % [ sn, hr, mn ]
552
+ elsif code == '%:z'
553
+ '%s%02d:%02d' % [ sn, hr, mn ]
554
+ else
555
+ '%s%02d:%02d:%02d' % [ sn, hr, mn, sc ]
556
+ end
557
557
  end
558
558
 
559
559
  def _to_f(o)
@@ -660,17 +660,34 @@ module EtOrbi
660
660
  mn = -mn if hr && hr < 0
661
661
 
662
662
  return (
663
- @custom_tz_cache[str] =
664
- begin
665
- tzi = TZInfo::TransitionDataTimezoneInfo.new(str)
666
- tzi.offset(str, hr * 3600 + mn * 60, 0, str)
667
- tzi.create_timezone
668
- end
663
+ @custom_tz_cache[str] = create_offset_tzone(hr * 3600 + mn * 60, str)
669
664
  ) if hr
670
665
 
671
666
  nil
672
667
  end
673
668
 
669
+ if defined? TZInfo::DataSources::ConstantOffsetDataTimezoneInfo
670
+ # TZInfo >= 2.0.0
671
+
672
+ def create_offset_tzone(utc_off, id)
673
+
674
+ off = TZInfo::TimezoneOffset.new(utc_off, 0, id)
675
+ tzi = TZInfo::DataSources::ConstantOffsetDataTimezoneInfo.new(id, off)
676
+ tzi.create_timezone
677
+ end
678
+
679
+ else
680
+ # TZInfo < 2.0.0
681
+
682
+ def create_offset_tzone(utc_off, id)
683
+
684
+ tzi = TZInfo::TransitionDataTimezoneInfo.new(id)
685
+ tzi.offset(id, utc_off, 0, id)
686
+ tzi.create_timezone
687
+ end
688
+
689
+ end
690
+
674
691
  def determine_local_tzones
675
692
 
676
693
  tabbs = (-6..5)
@@ -679,7 +696,7 @@ module EtOrbi
679
696
  .sort
680
697
 
681
698
  t = Time.now
682
- tu = t.dup.utc # /!\ dup is necessary, #utc modifies its target
699
+ #tu = t.dup.utc # /!\ dup is necessary, #utc modifies its target
683
700
 
684
701
  twin = Time.utc(t.year, 1, 1) # winter
685
702
  tsum = Time.utc(t.year, 7, 1) # summer
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.8
4
+ version: 1.0.9
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-24 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo