rrule 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/rrule/rule.rb +5 -5
- data/rrule.gemspec +1 -1
- data/spec/rule_spec.rb +18 -0
- 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: 1aad8dd06524a47f1d310b7f077db21f41696bc7
|
4
|
+
data.tar.gz: f2e1673c1fd07da16c47fc96e944eeabef43578b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa77f6132a2d47a45d8aab0a58af68a1ccd0417e22a9c2fc6ef4a2b14aef90e65040324177893773cba2b06e74373776105a19e078c5d81360f5e894b2cdec3c
|
7
|
+
data.tar.gz: 4fddc6b136db1d57c8d8e89fe099820e572f13fc447647cdd7c43942a74112255c8720ad2b8c82a0cb1586a8a1bdb0e862ec12014f6f05c5982a86ce58207518
|
data/CHANGELOG.md
CHANGED
data/lib/rrule/rule.rb
CHANGED
@@ -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 =
|
23
|
-
floored_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
|
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
|
data/rrule.gemspec
CHANGED
data/spec/rule_spec.rb
CHANGED
@@ -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.
|
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.
|
112
|
+
rubygems_version: 2.4.8
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: RRule expansion
|