rrule 0.4.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 524b148cf5608df2145bb75da8b5bca29867a30a
4
- data.tar.gz: d258adb876e71ce558ffa5831d2964ddd9263e00
3
+ metadata.gz: 1aad8dd06524a47f1d310b7f077db21f41696bc7
4
+ data.tar.gz: f2e1673c1fd07da16c47fc96e944eeabef43578b
5
5
  SHA512:
6
- metadata.gz: 47e40a473aaf70514150dc11c6779cb3bb31e2d985324416df60515e678bd111fae56a2ff84529e4deab3572c477fa7cdbcfc1437f1e429db25056e1564f026b
7
- data.tar.gz: 02ff7616862c0307a838f04eb4714fb57f9d261991199c09560ef51dd4d0c6cb223f4d2ff584d2ac94d09337b5dbd00c8a4bb96a6a52bdf1f7a02c34e680acab
6
+ metadata.gz: fa77f6132a2d47a45d8aab0a58af68a1ccd0417e22a9c2fc6ef4a2b14aef90e65040324177893773cba2b06e74373776105a19e078c5d81360f5e894b2cdec3c
7
+ data.tar.gz: 4fddc6b136db1d57c8d8e89fe099820e572f13fc447647cdd7c43942a74112255c8720ad2b8c82a0cb1586a8a1bdb0e862ec12014f6f05c5982a86ce58207518
@@ -1,6 +1,11 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 0.4.1 *(2018-11-28)*
5
+ ----------------------------
6
+ Fix bug in SimpleWeekly when ENV['TZ'] was not equal to time zone of rrule
7
+
8
+
4
9
  Version 0.1.0 *(2017-06-06)*
5
10
  ----------------------------
6
11
 
@@ -5,8 +5,8 @@ module RRule
5
5
  attr_reader :dtstart, :tz, :exdate
6
6
 
7
7
  def initialize(rrule, dtstart: Time.now, tzid: 'UTC', exdate: [], max_year: nil)
8
- @dtstart = floor_to_seconds(dtstart).in_time_zone(tzid)
9
8
  @tz = tzid
9
+ @dtstart = floor_to_seconds_in_timezone(dtstart)
10
10
  @exdate = exdate
11
11
  @options = parse_options(rrule)
12
12
  @frequency_type = Frequency.for_options(options)
@@ -19,8 +19,8 @@ module RRule
19
19
  end
20
20
 
21
21
  def between(start_date, end_date, limit: nil)
22
- floored_start_date = floor_to_seconds(start_date)
23
- floored_end_date = floor_to_seconds(end_date)
22
+ floored_start_date = floor_to_seconds_in_timezone(start_date)
23
+ floored_end_date = floor_to_seconds_in_timezone(end_date)
24
24
  all_until(start_date: floored_start_date, end_date: floored_end_date, limit: limit).reject { |instance| instance < floored_start_date }
25
25
  end
26
26
 
@@ -88,11 +88,11 @@ module RRule
88
88
 
89
89
  attr_reader :options, :max_year, :max_date, :frequency_type
90
90
 
91
- def floor_to_seconds(date)
91
+ def floor_to_seconds_in_timezone(date)
92
92
  # This removes all sub-second and floors it to the second level.
93
93
  # Sub-second level calculations breaks a lot of assumptions in this
94
94
  # library and rounding it may also cause unexpected inequalities.
95
- Time.at(date.to_i)
95
+ Time.at(date.to_i).in_time_zone(tz)
96
96
  end
97
97
 
98
98
  def enumerator
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rrule'
3
- s.version = '0.4.0'
3
+ s.version = '0.4.1'
4
4
  s.date = '2018-04-24'
5
5
  s.summary = 'RRule expansion'
6
6
  s.description = 'A gem for expanding dates according to the RRule specification'
@@ -1789,6 +1789,24 @@ describe RRule::Rule do
1789
1789
  end
1790
1790
 
1791
1791
  describe '#between' do
1792
+ context 'server env timezone is different from the passed timezone' do
1793
+ around do |example|
1794
+ old_tz = ENV['TZ']
1795
+ ENV['TZ'] = 'UTC'
1796
+ example.run
1797
+ ENV['TZ'] = old_tz
1798
+ end
1799
+
1800
+ it 'works when the day in the given timezone is different from the day in the server timezone' do
1801
+ # any time from 17:00 to 23:59:59 broke old code, test all hours of the day
1802
+ 0.upto(23) do |hour|
1803
+ dtstart = Time.new(2018, 7, 1, hour, 0, 0, '-07:00')
1804
+ rrule = RRule::Rule.new('FREQ=WEEKLY', dtstart: dtstart, tzid: 'America/Los_Angeles')
1805
+ expect(rrule.between(dtstart, dtstart + 1.second)).to eq([dtstart])
1806
+ end
1807
+ end
1808
+ end
1809
+
1792
1810
  it 'returns the correct result with an rrule of FREQ=WEEKLY;BYSECOND=59;BYMINUTE=59;BYHOUR=23;WKST=SU' do
1793
1811
  rrule = 'FREQ=WEEKLY;BYSECOND=59;BYMINUTE=59;BYHOUR=23;WKST=SU'
1794
1812
  dtstart = DateTime.parse('2018-02-04 04:00:00 +1000')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mitchell
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.6.13
112
+ rubygems_version: 2.4.8
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: RRule expansion