rrule 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +3 -0
  4. data/CHANGELOG.md +7 -0
  5. data/CONTRIBUTING.md +17 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE.txt +202 -0
  8. data/README.md +71 -0
  9. data/Rakefile +30 -0
  10. data/lib/rrule.rb +26 -4
  11. data/lib/rrule/context.rb +137 -0
  12. data/lib/rrule/filters/by_month.rb +16 -0
  13. data/lib/rrule/filters/by_month_day.rb +16 -0
  14. data/lib/rrule/filters/by_week_day.rb +24 -0
  15. data/lib/rrule/filters/by_week_number.rb +16 -0
  16. data/lib/rrule/filters/by_year_day.rb +18 -0
  17. data/lib/rrule/frequencies/daily.rb +13 -0
  18. data/lib/rrule/frequencies/frequency.rb +34 -0
  19. data/lib/rrule/frequencies/monthly.rb +14 -0
  20. data/lib/rrule/frequencies/weekly.rb +29 -0
  21. data/lib/rrule/frequencies/yearly.rb +14 -0
  22. data/lib/rrule/generators/all_occurrences.rb +26 -0
  23. data/lib/rrule/generators/by_set_position.rb +35 -0
  24. data/lib/rrule/rule.rb +181 -0
  25. data/lib/rrule/weekday.rb +17 -0
  26. data/rrule.gemspec +20 -0
  27. data/spec/context_spec.rb +261 -0
  28. data/spec/filters/by_month_day_spec.rb +35 -0
  29. data/spec/filters/by_month_spec.rb +35 -0
  30. data/spec/filters/by_week_day_spec.rb +35 -0
  31. data/spec/filters/by_week_number_spec.rb +41 -0
  32. data/spec/filters/by_year_day_spec.rb +35 -0
  33. data/spec/frequencies/daily_spec.rb +55 -0
  34. data/spec/frequencies/monthly_spec.rb +57 -0
  35. data/spec/frequencies/weekly_spec.rb +57 -0
  36. data/spec/frequencies/yearly_spec.rb +52 -0
  37. data/spec/generators/all_occurrences_spec.rb +44 -0
  38. data/spec/generators/by_set_position_spec.rb +39 -0
  39. data/spec/rule_spec.rb +1988 -0
  40. data/spec/spec_helper.rb +21 -0
  41. data/spec/weekday_spec.rb +34 -0
  42. metadata +88 -8
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::ByYearDay do
4
+ let(:context) do
5
+ RRule::Context.new(
6
+ { freq: 'YEARLY', count: 4 },
7
+ Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
+ 'America/Los_Angeles'
9
+ )
10
+ end
11
+
12
+ subject { described_class.new([45, -45], context).reject?(date.yday - 1) }
13
+
14
+ before(:each) { context.rebuild(1997, 1) }
15
+
16
+ describe '#reject?' do
17
+ context 'for the 45th day of the year' do
18
+ let(:date) { Date.new(1997, 2, 14) }
19
+
20
+ it { is_expected.to be false }
21
+ end
22
+
23
+ context 'for the 60th day of the year' do
24
+ let(:date) { Date.new(1997, 3, 1) }
25
+
26
+ it { is_expected.to be true }
27
+ end
28
+
29
+ context 'for the 45th-from-last day of the month' do
30
+ let(:date) { Date.new(1997, 11, 17) }
31
+
32
+ it { is_expected.to be false }
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::Daily do
4
+ let(:context) do
5
+ RRule::Context.new(
6
+ { interval: 1 },
7
+ date,
8
+ 'America/Los_Angeles'
9
+ )
10
+ end
11
+
12
+ describe '#possible_days' do
13
+ subject { described_class.new(context).possible_days }
14
+
15
+ context 'on the first day of the year' do
16
+ let(:date) { Date.new(1997, 1, 1)}
17
+
18
+ it { is_expected.to eql [0] }
19
+ end
20
+
21
+ context 'on a day in the first month' do
22
+ let(:date) { Date.new(1997, 1, 25)}
23
+
24
+ it { is_expected.to eql [24] }
25
+ end
26
+
27
+ context 'on a day in the next month' do
28
+ let(:date) { Date.new(1997, 2, 25)}
29
+
30
+ it { is_expected.to eql [55] }
31
+ end
32
+ end
33
+
34
+ describe '#advance' do
35
+ subject { described_class.new(context).advance }
36
+
37
+ context 'on the first day of the year' do
38
+ let(:date) { Date.new(1997, 1, 1)}
39
+
40
+ it { is_expected.to eql date + 1.day }
41
+ end
42
+
43
+ context 'on the last day of February' do
44
+ let(:date) { Date.new(1997, 2, 28)}
45
+
46
+ it { is_expected.to eql date + 1.day }
47
+ end
48
+
49
+ context 'on the last day of the year' do
50
+ let(:date) { Date.new(1997, 12, 31)}
51
+
52
+ it { is_expected.to eql date + 1.day }
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::Monthly do
4
+ let(:context) do
5
+ RRule::Context.new(
6
+ { interval: 1 },
7
+ date,
8
+ 'America/Los_Angeles'
9
+ )
10
+ end
11
+
12
+ before(:each) { context.rebuild(1997, 1) }
13
+
14
+ describe '#possible_days' do
15
+ subject { described_class.new(context).possible_days }
16
+
17
+ context 'on the first day of the year' do
18
+ let(:date) { Date.new(1997, 1, 1)}
19
+
20
+ it { is_expected.to eql (0..30).to_a }
21
+ end
22
+
23
+ context 'on a day in the first month' do
24
+ let(:date) { Date.new(1997, 1, 25)}
25
+
26
+ it { is_expected.to eql (0..30).to_a }
27
+ end
28
+
29
+ context 'on a day in the next month' do
30
+ let(:date) { Date.new(1997, 2, 25)}
31
+
32
+ it { is_expected.to eql (31..58).to_a }
33
+ end
34
+ end
35
+
36
+ describe '#advance' do
37
+ subject { described_class.new(context).advance }
38
+
39
+ context 'on the first day of the year' do
40
+ let(:date) { Date.new(1997, 1, 1)}
41
+
42
+ it { is_expected.to eql date + 1.month }
43
+ end
44
+
45
+ context 'on the last day of February' do
46
+ let(:date) { Date.new(1997, 2, 28)}
47
+
48
+ it { is_expected.to eql date + 1.month }
49
+ end
50
+
51
+ context 'on the last day of the year' do
52
+ let(:date) { Date.new(1997, 12, 31)}
53
+
54
+ it { is_expected.to eql date + 1.month }
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::Weekly do
4
+ let(:context) do
5
+ RRule::Context.new(
6
+ { interval: 1, wkst: 1 },
7
+ date,
8
+ 'America/Los_Angeles'
9
+ )
10
+ end
11
+
12
+ before(:each) { context.rebuild(1997, 1) }
13
+
14
+ describe '#possible_days' do
15
+ subject { described_class.new(context).possible_days }
16
+
17
+ context 'on the first day of the year with five days left in the week' do
18
+ let(:date) { Date.new(1997, 1, 1)}
19
+
20
+ it { is_expected.to eql (0..4).to_a }
21
+ end
22
+
23
+ context 'on a day in the first month with two days left in the week' do
24
+ let(:date) { Date.new(1997, 1, 25)}
25
+
26
+ it { is_expected.to eql (24..25).to_a }
27
+ end
28
+
29
+ context 'on a day in the next month with six days left in the week' do
30
+ let(:date) { Date.new(1997, 2, 25)}
31
+
32
+ it { is_expected.to eql (55..60).to_a }
33
+ end
34
+ end
35
+
36
+ describe '#advance' do
37
+ subject { described_class.new(context).advance }
38
+
39
+ context 'on the first day of the year' do
40
+ let(:date) { Date.new(1997, 1, 1)}
41
+
42
+ it { is_expected.to eql date.next_week }
43
+ end
44
+
45
+ context 'on the last day of February' do
46
+ let(:date) { Date.new(1997, 2, 28)}
47
+
48
+ it { is_expected.to eql date.next_week }
49
+ end
50
+
51
+ context 'on the last day of the year' do
52
+ let(:date) { Date.new(1997, 12, 31)}
53
+
54
+ it { is_expected.to eql date.next_week }
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::Yearly do
4
+ let(:date) { Date.new(1997, 1, 1) }
5
+ let(:context) do
6
+ RRule::Context.new(
7
+ { interval: 1, wkst: 1 },
8
+ date,
9
+ 'America/Los_Angeles'
10
+ )
11
+ end
12
+
13
+ before(:each) { context.rebuild(1997, 1) }
14
+
15
+ describe '#possible_days' do
16
+ subject { described_class.new(context).possible_days }
17
+
18
+ context 'in a non leap year' do
19
+ before(:each) { context.rebuild(1997, 1) }
20
+
21
+ it { is_expected.to eql (0..364).to_a }
22
+ end
23
+
24
+ context 'in a leap year' do
25
+ before(:each) { context.rebuild(2000, 1) }
26
+
27
+ it { is_expected.to eql (0..365).to_a }
28
+ end
29
+ end
30
+
31
+ describe '#advance' do
32
+ subject { described_class.new(context).advance }
33
+
34
+ context 'on the first day of the year' do
35
+ let(:date) { Date.new(1997, 1, 1)}
36
+
37
+ it { is_expected.to eql date + 1.year }
38
+ end
39
+
40
+ context 'on the last day of February' do
41
+ let(:date) { Date.new(1997, 2, 28)}
42
+
43
+ it { is_expected.to eql date + 1.year }
44
+ end
45
+
46
+ context 'on the last day of the year' do
47
+ let(:date) { Date.new(1997, 12, 31)}
48
+
49
+ it { is_expected.to eql date + 1.year }
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::AllOccurrences do
4
+ let(:context) do
5
+ RRule::Context.new(
6
+ { interval: 1, wkst: 1 },
7
+ Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
+ 'America/Los_Angeles'
9
+ )
10
+ end
11
+
12
+ around(:each) do |example|
13
+ Time.use_zone('America/Los_Angeles') do
14
+ example.run
15
+ end
16
+ end
17
+
18
+ before(:each) { context.rebuild(1997, 1) }
19
+
20
+ describe '#combine_dates_and_times' do
21
+ subject { described_class.new(context).combine_dates_and_times(dates, times)}
22
+
23
+ context 'with a single date and time' do
24
+ let(:dates) { [0] }
25
+ let(:times) { [{ hour: 12, minute: 30, second: 15 }] }
26
+
27
+ it { is_expected.to match_array [Time.new(1997, 1, 1, 12, 30, 15)] }
28
+ end
29
+
30
+ context 'with multiple dates and a single time' do
31
+ let(:dates) { [0, 15] }
32
+ let(:times) { [{ hour: 12, minute: 30, second: 15 }] }
33
+
34
+ it { is_expected.to match_array [Time.new(1997, 1, 1, 12, 30, 15), Time.new(1997, 1, 16, 12, 30, 15)] }
35
+ end
36
+
37
+ context 'with a single date and multiple times' do
38
+ let(:dates) { [0] }
39
+ let(:times) { [{ hour: 12, minute: 30, second: 15 }, { hour: 18, minute: 45, second: 20 }] }
40
+
41
+ it { is_expected.to match_array [Time.new(1997, 1, 1, 12, 30, 15), Time.new(1997, 1, 1, 18, 45, 20)] }
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::BySetPosition do
4
+ let(:context) do
5
+ RRule::Context.new(
6
+ { interval: 1, wkst: 1 },
7
+ Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
+ 'America/Los_Angeles'
9
+ )
10
+ end
11
+
12
+ around(:each) do |example|
13
+ Time.use_zone('America/Los_Angeles') do
14
+ example.run
15
+ end
16
+ end
17
+
18
+ before(:each) { context.rebuild(1997, 1) }
19
+
20
+ describe '#combine_dates_and_times' do
21
+ subject { described_class.new(positions, context).combine_dates_and_times(dates, times)}
22
+
23
+ context 'with a single set position' do
24
+ let(:positions) { [0] }
25
+ let(:dates) { [0, 1, 2, 3, 4] }
26
+ let(:times) { [{ hour: 12, minute: 30, second: 15 }] }
27
+
28
+ it { is_expected.to match_array [Time.new(1997, 1, 1, 12, 30, 15)] }
29
+ end
30
+
31
+ context 'with multiple set positions' do
32
+ let(:positions) { [1, 3] }
33
+ let(:dates) { [0, 1, 2, 3, 4] }
34
+ let(:times) { [{ hour: 12, minute: 30, second: 15 }] }
35
+
36
+ it { is_expected.to match_array [Time.new(1997, 1, 1, 12, 30, 15), Time.new(1997, 1, 3, 12, 30, 15)] }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,1988 @@
1
+ require 'spec_helper'
2
+
3
+ describe RRule::Rule do
4
+ describe '#all' do
5
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=10' do
6
+ rrule = 'FREQ=DAILY;COUNT=10'
7
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
8
+ timezone = 'America/New_York'
9
+
10
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
11
+ expect(rrule.all).to match_array([
12
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
13
+ Time.parse('Wed Sep 3 06:00:00 PDT 1997'),
14
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
15
+ Time.parse('Fri Sep 5 06:00:00 PDT 1997'),
16
+ Time.parse('Sat Sep 6 06:00:00 PDT 1997'),
17
+ Time.parse('Sun Sep 7 06:00:00 PDT 1997'),
18
+ Time.parse('Mon Sep 8 06:00:00 PDT 1997'),
19
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
20
+ Time.parse('Wed Sep 10 06:00:00 PDT 1997'),
21
+ Time.parse('Thu Sep 11 06:00:00 PDT 1997')
22
+ ])
23
+ end
24
+
25
+ it 'returns the correct result with an rrule of FREQ=DAILY;UNTIL=19971224T000000Z' do
26
+ rrule = 'FREQ=DAILY;UNTIL=19971224T000000Z'
27
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
28
+ timezone = 'America/New_York'
29
+
30
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
31
+ expect(rrule.all).to match_array([
32
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
33
+ Time.parse('Wed Sep 3 06:00:00 PDT 1997'),
34
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
35
+ Time.parse('Fri Sep 5 06:00:00 PDT 1997'),
36
+ Time.parse('Sat Sep 6 06:00:00 PDT 1997'),
37
+ Time.parse('Sun Sep 7 06:00:00 PDT 1997'),
38
+ Time.parse('Mon Sep 8 06:00:00 PDT 1997'),
39
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
40
+ Time.parse('Wed Sep 10 06:00:00 PDT 1997'),
41
+ Time.parse('Thu Sep 11 06:00:00 PDT 1997'),
42
+ Time.parse('Fri Sep 12 06:00:00 PDT 1997'),
43
+ Time.parse('Sat Sep 13 06:00:00 PDT 1997'),
44
+ Time.parse('Sun Sep 14 06:00:00 PDT 1997'),
45
+ Time.parse('Mon Sep 15 06:00:00 PDT 1997'),
46
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
47
+ Time.parse('Wed Sep 17 06:00:00 PDT 1997'),
48
+ Time.parse('Thu Sep 18 06:00:00 PDT 1997'),
49
+ Time.parse('Fri Sep 19 06:00:00 PDT 1997'),
50
+ Time.parse('Sat Sep 20 06:00:00 PDT 1997'),
51
+ Time.parse('Sun Sep 21 06:00:00 PDT 1997'),
52
+ Time.parse('Mon Sep 22 06:00:00 PDT 1997'),
53
+ Time.parse('Tue Sep 23 06:00:00 PDT 1997'),
54
+ Time.parse('Wed Sep 24 06:00:00 PDT 1997'),
55
+ Time.parse('Thu Sep 25 06:00:00 PDT 1997'),
56
+ Time.parse('Fri Sep 26 06:00:00 PDT 1997'),
57
+ Time.parse('Sat Sep 27 06:00:00 PDT 1997'),
58
+ Time.parse('Sun Sep 28 06:00:00 PDT 1997'),
59
+ Time.parse('Mon Sep 29 06:00:00 PDT 1997'),
60
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
61
+ Time.parse('Wed Oct 1 06:00:00 PDT 1997'),
62
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997'),
63
+ Time.parse('Fri Oct 3 06:00:00 PDT 1997'),
64
+ Time.parse('Sat Oct 4 06:00:00 PDT 1997'),
65
+ Time.parse('Sun Oct 5 06:00:00 PDT 1997'),
66
+ Time.parse('Mon Oct 6 06:00:00 PDT 1997'),
67
+ Time.parse('Tue Oct 7 06:00:00 PDT 1997'),
68
+ Time.parse('Wed Oct 8 06:00:00 PDT 1997'),
69
+ Time.parse('Thu Oct 9 06:00:00 PDT 1997'),
70
+ Time.parse('Fri Oct 10 06:00:00 PDT 1997'),
71
+ Time.parse('Sat Oct 11 06:00:00 PDT 1997'),
72
+ Time.parse('Sun Oct 12 06:00:00 PDT 1997'),
73
+ Time.parse('Mon Oct 13 06:00:00 PDT 1997'),
74
+ Time.parse('Tue Oct 14 06:00:00 PDT 1997'),
75
+ Time.parse('Wed Oct 15 06:00:00 PDT 1997'),
76
+ Time.parse('Thu Oct 16 06:00:00 PDT 1997'),
77
+ Time.parse('Fri Oct 17 06:00:00 PDT 1997'),
78
+ Time.parse('Sat Oct 18 06:00:00 PDT 1997'),
79
+ Time.parse('Sun Oct 19 06:00:00 PDT 1997'),
80
+ Time.parse('Mon Oct 20 06:00:00 PDT 1997'),
81
+ Time.parse('Tue Oct 21 06:00:00 PDT 1997'),
82
+ Time.parse('Wed Oct 22 06:00:00 PDT 1997'),
83
+ Time.parse('Thu Oct 23 06:00:00 PDT 1997'),
84
+ Time.parse('Fri Oct 24 06:00:00 PDT 1997'),
85
+ Time.parse('Sat Oct 25 06:00:00 PDT 1997'),
86
+ Time.parse('Sun Oct 26 06:00:00 PST 1997'),
87
+ Time.parse('Mon Oct 27 06:00:00 PST 1997'),
88
+ Time.parse('Tue Oct 28 06:00:00 PST 1997'),
89
+ Time.parse('Wed Oct 29 06:00:00 PST 1997'),
90
+ Time.parse('Thu Oct 30 06:00:00 PST 1997'),
91
+ Time.parse('Fri Oct 31 06:00:00 PST 1997'),
92
+ Time.parse('Sat Nov 1 06:00:00 PST 1997'),
93
+ Time.parse('Sun Nov 2 06:00:00 PST 1997'),
94
+ Time.parse('Mon Nov 3 06:00:00 PST 1997'),
95
+ Time.parse('Tue Nov 4 06:00:00 PST 1997'),
96
+ Time.parse('Wed Nov 5 06:00:00 PST 1997'),
97
+ Time.parse('Thu Nov 6 06:00:00 PST 1997'),
98
+ Time.parse('Fri Nov 7 06:00:00 PST 1997'),
99
+ Time.parse('Sat Nov 8 06:00:00 PST 1997'),
100
+ Time.parse('Sun Nov 9 06:00:00 PST 1997'),
101
+ Time.parse('Mon Nov 10 06:00:00 PST 1997'),
102
+ Time.parse('Tue Nov 11 06:00:00 PST 1997'),
103
+ Time.parse('Wed Nov 12 06:00:00 PST 1997'),
104
+ Time.parse('Thu Nov 13 06:00:00 PST 1997'),
105
+ Time.parse('Fri Nov 14 06:00:00 PST 1997'),
106
+ Time.parse('Sat Nov 15 06:00:00 PST 1997'),
107
+ Time.parse('Sun Nov 16 06:00:00 PST 1997'),
108
+ Time.parse('Mon Nov 17 06:00:00 PST 1997'),
109
+ Time.parse('Tue Nov 18 06:00:00 PST 1997'),
110
+ Time.parse('Wed Nov 19 06:00:00 PST 1997'),
111
+ Time.parse('Thu Nov 20 06:00:00 PST 1997'),
112
+ Time.parse('Fri Nov 21 06:00:00 PST 1997'),
113
+ Time.parse('Sat Nov 22 06:00:00 PST 1997'),
114
+ Time.parse('Sun Nov 23 06:00:00 PST 1997'),
115
+ Time.parse('Mon Nov 24 06:00:00 PST 1997'),
116
+ Time.parse('Tue Nov 25 06:00:00 PST 1997'),
117
+ Time.parse('Wed Nov 26 06:00:00 PST 1997'),
118
+ Time.parse('Thu Nov 27 06:00:00 PST 1997'),
119
+ Time.parse('Fri Nov 28 06:00:00 PST 1997'),
120
+ Time.parse('Sat Nov 29 06:00:00 PST 1997'),
121
+ Time.parse('Sun Nov 30 06:00:00 PST 1997'),
122
+ Time.parse('Mon Dec 1 06:00:00 PST 1997'),
123
+ Time.parse('Tue Dec 2 06:00:00 PST 1997'),
124
+ Time.parse('Wed Dec 3 06:00:00 PST 1997'),
125
+ Time.parse('Thu Dec 4 06:00:00 PST 1997'),
126
+ Time.parse('Fri Dec 5 06:00:00 PST 1997'),
127
+ Time.parse('Sat Dec 6 06:00:00 PST 1997'),
128
+ Time.parse('Sun Dec 7 06:00:00 PST 1997'),
129
+ Time.parse('Mon Dec 8 06:00:00 PST 1997'),
130
+ Time.parse('Tue Dec 9 06:00:00 PST 1997'),
131
+ Time.parse('Wed Dec 10 06:00:00 PST 1997'),
132
+ Time.parse('Thu Dec 11 06:00:00 PST 1997'),
133
+ Time.parse('Fri Dec 12 06:00:00 PST 1997'),
134
+ Time.parse('Sat Dec 13 06:00:00 PST 1997'),
135
+ Time.parse('Sun Dec 14 06:00:00 PST 1997'),
136
+ Time.parse('Mon Dec 15 06:00:00 PST 1997'),
137
+ Time.parse('Tue Dec 16 06:00:00 PST 1997'),
138
+ Time.parse('Wed Dec 17 06:00:00 PST 1997'),
139
+ Time.parse('Thu Dec 18 06:00:00 PST 1997'),
140
+ Time.parse('Fri Dec 19 06:00:00 PST 1997'),
141
+ Time.parse('Sat Dec 20 06:00:00 PST 1997'),
142
+ Time.parse('Sun Dec 21 06:00:00 PST 1997'),
143
+ Time.parse('Mon Dec 22 06:00:00 PST 1997'),
144
+ Time.parse('Tue Dec 23 06:00:00 PST 1997')
145
+ ])
146
+ end
147
+
148
+ it 'returns the correct result with an rrule of FREQ=DAILY;INTERVAL=10;COUNT=5' do
149
+ rrule = 'FREQ=DAILY;INTERVAL=10;COUNT=5'
150
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
151
+ timezone = 'America/New_York'
152
+
153
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
154
+ expect(rrule.all).to match_array([
155
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
156
+ Time.parse('Fri Sep 12 06:00:00 PDT 1997'),
157
+ Time.parse('Mon Sep 22 06:00:00 PDT 1997'),
158
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997'),
159
+ Time.parse('Sun Oct 12 06:00:00 PDT 1997')
160
+ ])
161
+ end
162
+
163
+ it 'returns the correct result with an rrule of FREQ=YEARLY;UNTIL=20000131T140000Z;BYMONTH=1;BYDAY=SU,MO,TU,WE,TH,FR,SA' do
164
+ rrule = 'FREQ=YEARLY;UNTIL=20000131T140000Z;BYMONTH=1;BYDAY=SU,MO,TU,WE,TH,FR,SA'
165
+ dtstart = Time.parse('Thu Jan 1 06:00:00 PST 1998')
166
+ timezone = 'America/New_York'
167
+
168
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
169
+ expect(rrule.all).to match_array([
170
+ Time.parse('Thu Jan 1 06:00:00 PST 1998'),
171
+ Time.parse('Fri Jan 2 06:00:00 PST 1998'),
172
+ Time.parse('Sat Jan 3 06:00:00 PST 1998'),
173
+ Time.parse('Sun Jan 4 06:00:00 PST 1998'),
174
+ Time.parse('Mon Jan 5 06:00:00 PST 1998'),
175
+ Time.parse('Tue Jan 6 06:00:00 PST 1998'),
176
+ Time.parse('Wed Jan 7 06:00:00 PST 1998'),
177
+ Time.parse('Thu Jan 8 06:00:00 PST 1998'),
178
+ Time.parse('Fri Jan 9 06:00:00 PST 1998'),
179
+ Time.parse('Sat Jan 10 06:00:00 PST 1998'),
180
+ Time.parse('Sun Jan 11 06:00:00 PST 1998'),
181
+ Time.parse('Mon Jan 12 06:00:00 PST 1998'),
182
+ Time.parse('Tue Jan 13 06:00:00 PST 1998'),
183
+ Time.parse('Wed Jan 14 06:00:00 PST 1998'),
184
+ Time.parse('Thu Jan 15 06:00:00 PST 1998'),
185
+ Time.parse('Fri Jan 16 06:00:00 PST 1998'),
186
+ Time.parse('Sat Jan 17 06:00:00 PST 1998'),
187
+ Time.parse('Sun Jan 18 06:00:00 PST 1998'),
188
+ Time.parse('Mon Jan 19 06:00:00 PST 1998'),
189
+ Time.parse('Tue Jan 20 06:00:00 PST 1998'),
190
+ Time.parse('Wed Jan 21 06:00:00 PST 1998'),
191
+ Time.parse('Thu Jan 22 06:00:00 PST 1998'),
192
+ Time.parse('Fri Jan 23 06:00:00 PST 1998'),
193
+ Time.parse('Sat Jan 24 06:00:00 PST 1998'),
194
+ Time.parse('Sun Jan 25 06:00:00 PST 1998'),
195
+ Time.parse('Mon Jan 26 06:00:00 PST 1998'),
196
+ Time.parse('Tue Jan 27 06:00:00 PST 1998'),
197
+ Time.parse('Wed Jan 28 06:00:00 PST 1998'),
198
+ Time.parse('Thu Jan 29 06:00:00 PST 1998'),
199
+ Time.parse('Fri Jan 30 06:00:00 PST 1998'),
200
+ Time.parse('Sat Jan 31 06:00:00 PST 1998'),
201
+ Time.parse('Fri Jan 1 06:00:00 PST 1999'),
202
+ Time.parse('Sat Jan 2 06:00:00 PST 1999'),
203
+ Time.parse('Sun Jan 3 06:00:00 PST 1999'),
204
+ Time.parse('Mon Jan 4 06:00:00 PST 1999'),
205
+ Time.parse('Tue Jan 5 06:00:00 PST 1999'),
206
+ Time.parse('Wed Jan 6 06:00:00 PST 1999'),
207
+ Time.parse('Thu Jan 7 06:00:00 PST 1999'),
208
+ Time.parse('Fri Jan 8 06:00:00 PST 1999'),
209
+ Time.parse('Sat Jan 9 06:00:00 PST 1999'),
210
+ Time.parse('Sun Jan 10 06:00:00 PST 1999'),
211
+ Time.parse('Mon Jan 11 06:00:00 PST 1999'),
212
+ Time.parse('Tue Jan 12 06:00:00 PST 1999'),
213
+ Time.parse('Wed Jan 13 06:00:00 PST 1999'),
214
+ Time.parse('Thu Jan 14 06:00:00 PST 1999'),
215
+ Time.parse('Fri Jan 15 06:00:00 PST 1999'),
216
+ Time.parse('Sat Jan 16 06:00:00 PST 1999'),
217
+ Time.parse('Sun Jan 17 06:00:00 PST 1999'),
218
+ Time.parse('Mon Jan 18 06:00:00 PST 1999'),
219
+ Time.parse('Tue Jan 19 06:00:00 PST 1999'),
220
+ Time.parse('Wed Jan 20 06:00:00 PST 1999'),
221
+ Time.parse('Thu Jan 21 06:00:00 PST 1999'),
222
+ Time.parse('Fri Jan 22 06:00:00 PST 1999'),
223
+ Time.parse('Sat Jan 23 06:00:00 PST 1999'),
224
+ Time.parse('Sun Jan 24 06:00:00 PST 1999'),
225
+ Time.parse('Mon Jan 25 06:00:00 PST 1999'),
226
+ Time.parse('Tue Jan 26 06:00:00 PST 1999'),
227
+ Time.parse('Wed Jan 27 06:00:00 PST 1999'),
228
+ Time.parse('Thu Jan 28 06:00:00 PST 1999'),
229
+ Time.parse('Fri Jan 29 06:00:00 PST 1999'),
230
+ Time.parse('Sat Jan 30 06:00:00 PST 1999'),
231
+ Time.parse('Sun Jan 31 06:00:00 PST 1999'),
232
+ Time.parse('Sat Jan 1 06:00:00 PST 2000'),
233
+ Time.parse('Sun Jan 2 06:00:00 PST 2000'),
234
+ Time.parse('Mon Jan 3 06:00:00 PST 2000'),
235
+ Time.parse('Tue Jan 4 06:00:00 PST 2000'),
236
+ Time.parse('Wed Jan 5 06:00:00 PST 2000'),
237
+ Time.parse('Thu Jan 6 06:00:00 PST 2000'),
238
+ Time.parse('Fri Jan 7 06:00:00 PST 2000'),
239
+ Time.parse('Sat Jan 8 06:00:00 PST 2000'),
240
+ Time.parse('Sun Jan 9 06:00:00 PST 2000'),
241
+ Time.parse('Mon Jan 10 06:00:00 PST 2000'),
242
+ Time.parse('Tue Jan 11 06:00:00 PST 2000'),
243
+ Time.parse('Wed Jan 12 06:00:00 PST 2000'),
244
+ Time.parse('Thu Jan 13 06:00:00 PST 2000'),
245
+ Time.parse('Fri Jan 14 06:00:00 PST 2000'),
246
+ Time.parse('Sat Jan 15 06:00:00 PST 2000'),
247
+ Time.parse('Sun Jan 16 06:00:00 PST 2000'),
248
+ Time.parse('Mon Jan 17 06:00:00 PST 2000'),
249
+ Time.parse('Tue Jan 18 06:00:00 PST 2000'),
250
+ Time.parse('Wed Jan 19 06:00:00 PST 2000'),
251
+ Time.parse('Thu Jan 20 06:00:00 PST 2000'),
252
+ Time.parse('Fri Jan 21 06:00:00 PST 2000'),
253
+ Time.parse('Sat Jan 22 06:00:00 PST 2000'),
254
+ Time.parse('Sun Jan 23 06:00:00 PST 2000'),
255
+ Time.parse('Mon Jan 24 06:00:00 PST 2000'),
256
+ Time.parse('Tue Jan 25 06:00:00 PST 2000'),
257
+ Time.parse('Wed Jan 26 06:00:00 PST 2000'),
258
+ Time.parse('Thu Jan 27 06:00:00 PST 2000'),
259
+ Time.parse('Fri Jan 28 06:00:00 PST 2000'),
260
+ Time.parse('Sat Jan 29 06:00:00 PST 2000'),
261
+ Time.parse('Sun Jan 30 06:00:00 PST 2000'),
262
+ Time.parse('Mon Jan 31 06:00:00 PST 2000')
263
+ ])
264
+ end
265
+
266
+ it 'returns the correct result with an rrule of FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1' do
267
+ rrule = 'FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1'
268
+ dtstart = Time.parse('Thu Jan 1 06:00:00 PST 1998')
269
+ timezone = 'America/New_York'
270
+
271
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
272
+ expect(rrule.all).to match_array([
273
+ Time.parse('Thu Jan 1 06:00:00 PST 1998'),
274
+ Time.parse('Fri Jan 2 06:00:00 PST 1998'),
275
+ Time.parse('Sat Jan 3 06:00:00 PST 1998'),
276
+ Time.parse('Sun Jan 4 06:00:00 PST 1998'),
277
+ Time.parse('Mon Jan 5 06:00:00 PST 1998'),
278
+ Time.parse('Tue Jan 6 06:00:00 PST 1998'),
279
+ Time.parse('Wed Jan 7 06:00:00 PST 1998'),
280
+ Time.parse('Thu Jan 8 06:00:00 PST 1998'),
281
+ Time.parse('Fri Jan 9 06:00:00 PST 1998'),
282
+ Time.parse('Sat Jan 10 06:00:00 PST 1998'),
283
+ Time.parse('Sun Jan 11 06:00:00 PST 1998'),
284
+ Time.parse('Mon Jan 12 06:00:00 PST 1998'),
285
+ Time.parse('Tue Jan 13 06:00:00 PST 1998'),
286
+ Time.parse('Wed Jan 14 06:00:00 PST 1998'),
287
+ Time.parse('Thu Jan 15 06:00:00 PST 1998'),
288
+ Time.parse('Fri Jan 16 06:00:00 PST 1998'),
289
+ Time.parse('Sat Jan 17 06:00:00 PST 1998'),
290
+ Time.parse('Sun Jan 18 06:00:00 PST 1998'),
291
+ Time.parse('Mon Jan 19 06:00:00 PST 1998'),
292
+ Time.parse('Tue Jan 20 06:00:00 PST 1998'),
293
+ Time.parse('Wed Jan 21 06:00:00 PST 1998'),
294
+ Time.parse('Thu Jan 22 06:00:00 PST 1998'),
295
+ Time.parse('Fri Jan 23 06:00:00 PST 1998'),
296
+ Time.parse('Sat Jan 24 06:00:00 PST 1998'),
297
+ Time.parse('Sun Jan 25 06:00:00 PST 1998'),
298
+ Time.parse('Mon Jan 26 06:00:00 PST 1998'),
299
+ Time.parse('Tue Jan 27 06:00:00 PST 1998'),
300
+ Time.parse('Wed Jan 28 06:00:00 PST 1998'),
301
+ Time.parse('Thu Jan 29 06:00:00 PST 1998'),
302
+ Time.parse('Fri Jan 30 06:00:00 PST 1998'),
303
+ Time.parse('Sat Jan 31 06:00:00 PST 1998'),
304
+ Time.parse('Fri Jan 1 06:00:00 PST 1999'),
305
+ Time.parse('Sat Jan 2 06:00:00 PST 1999'),
306
+ Time.parse('Sun Jan 3 06:00:00 PST 1999'),
307
+ Time.parse('Mon Jan 4 06:00:00 PST 1999'),
308
+ Time.parse('Tue Jan 5 06:00:00 PST 1999'),
309
+ Time.parse('Wed Jan 6 06:00:00 PST 1999'),
310
+ Time.parse('Thu Jan 7 06:00:00 PST 1999'),
311
+ Time.parse('Fri Jan 8 06:00:00 PST 1999'),
312
+ Time.parse('Sat Jan 9 06:00:00 PST 1999'),
313
+ Time.parse('Sun Jan 10 06:00:00 PST 1999'),
314
+ Time.parse('Mon Jan 11 06:00:00 PST 1999'),
315
+ Time.parse('Tue Jan 12 06:00:00 PST 1999'),
316
+ Time.parse('Wed Jan 13 06:00:00 PST 1999'),
317
+ Time.parse('Thu Jan 14 06:00:00 PST 1999'),
318
+ Time.parse('Fri Jan 15 06:00:00 PST 1999'),
319
+ Time.parse('Sat Jan 16 06:00:00 PST 1999'),
320
+ Time.parse('Sun Jan 17 06:00:00 PST 1999'),
321
+ Time.parse('Mon Jan 18 06:00:00 PST 1999'),
322
+ Time.parse('Tue Jan 19 06:00:00 PST 1999'),
323
+ Time.parse('Wed Jan 20 06:00:00 PST 1999'),
324
+ Time.parse('Thu Jan 21 06:00:00 PST 1999'),
325
+ Time.parse('Fri Jan 22 06:00:00 PST 1999'),
326
+ Time.parse('Sat Jan 23 06:00:00 PST 1999'),
327
+ Time.parse('Sun Jan 24 06:00:00 PST 1999'),
328
+ Time.parse('Mon Jan 25 06:00:00 PST 1999'),
329
+ Time.parse('Tue Jan 26 06:00:00 PST 1999'),
330
+ Time.parse('Wed Jan 27 06:00:00 PST 1999'),
331
+ Time.parse('Thu Jan 28 06:00:00 PST 1999'),
332
+ Time.parse('Fri Jan 29 06:00:00 PST 1999'),
333
+ Time.parse('Sat Jan 30 06:00:00 PST 1999'),
334
+ Time.parse('Sun Jan 31 06:00:00 PST 1999'),
335
+ Time.parse('Sat Jan 1 06:00:00 PST 2000'),
336
+ Time.parse('Sun Jan 2 06:00:00 PST 2000'),
337
+ Time.parse('Mon Jan 3 06:00:00 PST 2000'),
338
+ Time.parse('Tue Jan 4 06:00:00 PST 2000'),
339
+ Time.parse('Wed Jan 5 06:00:00 PST 2000'),
340
+ Time.parse('Thu Jan 6 06:00:00 PST 2000'),
341
+ Time.parse('Fri Jan 7 06:00:00 PST 2000'),
342
+ Time.parse('Sat Jan 8 06:00:00 PST 2000'),
343
+ Time.parse('Sun Jan 9 06:00:00 PST 2000'),
344
+ Time.parse('Mon Jan 10 06:00:00 PST 2000'),
345
+ Time.parse('Tue Jan 11 06:00:00 PST 2000'),
346
+ Time.parse('Wed Jan 12 06:00:00 PST 2000'),
347
+ Time.parse('Thu Jan 13 06:00:00 PST 2000'),
348
+ Time.parse('Fri Jan 14 06:00:00 PST 2000'),
349
+ Time.parse('Sat Jan 15 06:00:00 PST 2000'),
350
+ Time.parse('Sun Jan 16 06:00:00 PST 2000'),
351
+ Time.parse('Mon Jan 17 06:00:00 PST 2000'),
352
+ Time.parse('Tue Jan 18 06:00:00 PST 2000'),
353
+ Time.parse('Wed Jan 19 06:00:00 PST 2000'),
354
+ Time.parse('Thu Jan 20 06:00:00 PST 2000'),
355
+ Time.parse('Fri Jan 21 06:00:00 PST 2000'),
356
+ Time.parse('Sat Jan 22 06:00:00 PST 2000'),
357
+ Time.parse('Sun Jan 23 06:00:00 PST 2000'),
358
+ Time.parse('Mon Jan 24 06:00:00 PST 2000'),
359
+ Time.parse('Tue Jan 25 06:00:00 PST 2000'),
360
+ Time.parse('Wed Jan 26 06:00:00 PST 2000'),
361
+ Time.parse('Thu Jan 27 06:00:00 PST 2000'),
362
+ Time.parse('Fri Jan 28 06:00:00 PST 2000'),
363
+ Time.parse('Sat Jan 29 06:00:00 PST 2000'),
364
+ Time.parse('Sun Jan 30 06:00:00 PST 2000'),
365
+ Time.parse('Mon Jan 31 06:00:00 PST 2000')
366
+ ])
367
+ end
368
+
369
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=10' do
370
+ rrule = 'FREQ=WEEKLY;COUNT=10'
371
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
372
+ timezone = 'America/New_York'
373
+
374
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
375
+ expect(rrule.all).to match_array([
376
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
377
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
378
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
379
+ Time.parse('Tue Sep 23 06:00:00 PDT 1997'),
380
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
381
+ Time.parse('Tue Oct 7 06:00:00 PDT 1997'),
382
+ Time.parse('Tue Oct 14 06:00:00 PDT 1997'),
383
+ Time.parse('Tue Oct 21 06:00:00 PDT 1997'),
384
+ Time.parse('Tue Oct 28 06:00:00 PST 1997'),
385
+ Time.parse('Tue Nov 4 06:00:00 PST 1997')
386
+ ])
387
+ end
388
+
389
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;UNTIL=19971224T000000Z' do
390
+ rrule = 'FREQ=WEEKLY;UNTIL=19971224T000000Z'
391
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
392
+ timezone = 'America/New_York'
393
+
394
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
395
+ expect(rrule.all).to match_array([
396
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
397
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
398
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
399
+ Time.parse('Tue Sep 23 06:00:00 PDT 1997'),
400
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
401
+ Time.parse('Tue Oct 7 06:00:00 PDT 1997'),
402
+ Time.parse('Tue Oct 14 06:00:00 PDT 1997'),
403
+ Time.parse('Tue Oct 21 06:00:00 PDT 1997'),
404
+ Time.parse('Tue Oct 28 06:00:00 PST 1997'),
405
+ Time.parse('Tue Nov 4 06:00:00 PST 1997'),
406
+ Time.parse('Tue Nov 11 06:00:00 PST 1997'),
407
+ Time.parse('Tue Nov 18 06:00:00 PST 1997'),
408
+ Time.parse('Tue Nov 25 06:00:00 PST 1997'),
409
+ Time.parse('Tue Dec 2 06:00:00 PST 1997'),
410
+ Time.parse('Tue Dec 9 06:00:00 PST 1997'),
411
+ Time.parse('Tue Dec 16 06:00:00 PST 1997'),
412
+ Time.parse('Tue Dec 23 06:00:00 PST 1997')
413
+ ])
414
+ end
415
+
416
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH' do
417
+ rrule = 'FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH'
418
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
419
+ timezone = 'America/New_York'
420
+
421
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
422
+ expect(rrule.all).to match_array([
423
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
424
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
425
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
426
+ Time.parse('Thu Sep 11 06:00:00 PDT 1997'),
427
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
428
+ Time.parse('Thu Sep 18 06:00:00 PDT 1997'),
429
+ Time.parse('Tue Sep 23 06:00:00 PDT 1997'),
430
+ Time.parse('Thu Sep 25 06:00:00 PDT 1997'),
431
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
432
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997')
433
+ ])
434
+ end
435
+
436
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH' do
437
+ rrule = 'FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH'
438
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
439
+ timezone = 'America/New_York'
440
+
441
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
442
+ expect(rrule.all).to match_array([
443
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
444
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
445
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
446
+ Time.parse('Thu Sep 11 06:00:00 PDT 1997'),
447
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
448
+ Time.parse('Thu Sep 18 06:00:00 PDT 1997'),
449
+ Time.parse('Tue Sep 23 06:00:00 PDT 1997'),
450
+ Time.parse('Thu Sep 25 06:00:00 PDT 1997'),
451
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
452
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997')
453
+ ])
454
+ end
455
+
456
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR' do
457
+ rrule = 'FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR'
458
+ dtstart = Time.parse('Mon Sep 1 06:00:00 PDT 1997')
459
+ timezone = 'America/New_York'
460
+
461
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
462
+ expect(rrule.all).to match_array([
463
+ Time.parse('Mon Sep 1 06:00:00 PDT 1997'),
464
+ Time.parse('Wed Sep 3 06:00:00 PDT 1997'),
465
+ Time.parse('Fri Sep 5 06:00:00 PDT 1997'),
466
+ Time.parse('Mon Sep 15 06:00:00 PDT 1997'),
467
+ Time.parse('Wed Sep 17 06:00:00 PDT 1997'),
468
+ Time.parse('Fri Sep 19 06:00:00 PDT 1997'),
469
+ Time.parse('Mon Sep 29 06:00:00 PDT 1997'),
470
+ Time.parse('Wed Oct 1 06:00:00 PDT 1997'),
471
+ Time.parse('Fri Oct 3 06:00:00 PDT 1997'),
472
+ Time.parse('Mon Oct 13 06:00:00 PDT 1997'),
473
+ Time.parse('Wed Oct 15 06:00:00 PDT 1997'),
474
+ Time.parse('Fri Oct 17 06:00:00 PDT 1997'),
475
+ Time.parse('Mon Oct 27 06:00:00 PST 1997'),
476
+ Time.parse('Wed Oct 29 06:00:00 PST 1997'),
477
+ Time.parse('Fri Oct 31 06:00:00 PST 1997'),
478
+ Time.parse('Mon Nov 10 06:00:00 PST 1997'),
479
+ Time.parse('Wed Nov 12 06:00:00 PST 1997'),
480
+ Time.parse('Fri Nov 14 06:00:00 PST 1997'),
481
+ Time.parse('Mon Nov 24 06:00:00 PST 1997'),
482
+ Time.parse('Wed Nov 26 06:00:00 PST 1997'),
483
+ Time.parse('Fri Nov 28 06:00:00 PST 1997'),
484
+ Time.parse('Mon Dec 8 06:00:00 PST 1997'),
485
+ Time.parse('Wed Dec 10 06:00:00 PST 1997'),
486
+ Time.parse('Fri Dec 12 06:00:00 PST 1997'),
487
+ Time.parse('Mon Dec 22 06:00:00 PST 1997')
488
+ ])
489
+ end
490
+
491
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH' do
492
+ rrule = 'FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH'
493
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
494
+ timezone = 'America/New_York'
495
+
496
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
497
+ expect(rrule.all).to match_array([
498
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
499
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
500
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
501
+ Time.parse('Thu Sep 18 06:00:00 PDT 1997'),
502
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
503
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997'),
504
+ Time.parse('Tue Oct 14 06:00:00 PDT 1997'),
505
+ Time.parse('Thu Oct 16 06:00:00 PDT 1997')
506
+ ])
507
+ end
508
+
509
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=10;BYDAY=1FR' do
510
+ rrule = 'FREQ=MONTHLY;COUNT=10;BYDAY=1FR'
511
+ dtstart = Time.parse('Fri Sep 5 06:00:00 PDT 1997')
512
+ timezone = 'America/New_York'
513
+
514
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
515
+ expect(rrule.all).to match_array([
516
+ Time.parse('Fri Sep 5 06:00:00 PDT 1997'),
517
+ Time.parse('Fri Oct 3 06:00:00 PDT 1997'),
518
+ Time.parse('Fri Nov 7 06:00:00 PST 1997'),
519
+ Time.parse('Fri Dec 5 06:00:00 PST 1997'),
520
+ Time.parse('Fri Jan 2 06:00:00 PST 1998'),
521
+ Time.parse('Fri Feb 6 06:00:00 PST 1998'),
522
+ Time.parse('Fri Mar 6 06:00:00 PST 1998'),
523
+ Time.parse('Fri Apr 3 06:00:00 PST 1998'),
524
+ Time.parse('Fri May 1 06:00:00 PDT 1998'),
525
+ Time.parse('Fri Jun 5 06:00:00 PDT 1998')
526
+ ])
527
+ end
528
+
529
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;UNTIL=19971224T000000Z;BYDAY=1FR' do
530
+ rrule = 'FREQ=MONTHLY;UNTIL=19971224T000000Z;BYDAY=1FR'
531
+ dtstart = Time.parse('Fri Sep 5 06:00:00 PDT 1997')
532
+ timezone = 'America/New_York'
533
+
534
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
535
+ expect(rrule.all).to match_array([
536
+ Time.parse('Fri Sep 5 06:00:00 PDT 1997'),
537
+ Time.parse('Fri Oct 3 06:00:00 PDT 1997'),
538
+ Time.parse('Fri Nov 7 06:00:00 PST 1997'),
539
+ Time.parse('Fri Dec 5 06:00:00 PST 1997')
540
+ ])
541
+ end
542
+
543
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=1SU,-1SU' do
544
+ rrule = 'FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=1SU,-1SU'
545
+ dtstart = Time.parse('Sun Sep 7 06:00:00 PDT 1997')
546
+ timezone = 'America/New_York'
547
+
548
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
549
+ expect(rrule.all).to match_array([
550
+ Time.parse('Sun Sep 7 06:00:00 PDT 1997'),
551
+ Time.parse('Sun Sep 28 06:00:00 PDT 1997'),
552
+ Time.parse('Sun Nov 2 06:00:00 PST 1997'),
553
+ Time.parse('Sun Nov 30 06:00:00 PST 1997'),
554
+ Time.parse('Sun Jan 4 06:00:00 PST 1998'),
555
+ Time.parse('Sun Jan 25 06:00:00 PST 1998'),
556
+ Time.parse('Sun Mar 1 06:00:00 PST 1998'),
557
+ Time.parse('Sun Mar 29 06:00:00 PST 1998'),
558
+ Time.parse('Sun May 3 06:00:00 PDT 1998'),
559
+ Time.parse('Sun May 31 06:00:00 PDT 1998')
560
+ ])
561
+ end
562
+
563
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=6;BYDAY=-2MO' do
564
+ rrule = 'FREQ=MONTHLY;COUNT=6;BYDAY=-2MO'
565
+ dtstart = Time.parse('Mon Sep 22 06:00:00 PDT 1997')
566
+ timezone = 'America/New_York'
567
+
568
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
569
+ expect(rrule.all).to match_array([
570
+ Time.parse('Mon Sep 22 06:00:00 PDT 1997'),
571
+ Time.parse('Mon Oct 20 06:00:00 PDT 1997'),
572
+ Time.parse('Mon Nov 17 06:00:00 PST 1997'),
573
+ Time.parse('Mon Dec 22 06:00:00 PST 1997'),
574
+ Time.parse('Mon Jan 19 06:00:00 PST 1998'),
575
+ Time.parse('Mon Feb 16 06:00:00 PST 1998')
576
+ ])
577
+ end
578
+
579
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=10;BYMONTHDAY=2,15' do
580
+ rrule = 'FREQ=MONTHLY;COUNT=10;BYMONTHDAY=2,15'
581
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
582
+ timezone = 'America/New_York'
583
+
584
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
585
+ expect(rrule.all).to match_array([
586
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
587
+ Time.parse('Mon Sep 15 06:00:00 PDT 1997'),
588
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997'),
589
+ Time.parse('Wed Oct 15 06:00:00 PDT 1997'),
590
+ Time.parse('Sun Nov 2 06:00:00 PST 1997'),
591
+ Time.parse('Sat Nov 15 06:00:00 PST 1997'),
592
+ Time.parse('Tue Dec 2 06:00:00 PST 1997'),
593
+ Time.parse('Mon Dec 15 06:00:00 PST 1997'),
594
+ Time.parse('Fri Jan 2 06:00:00 PST 1998'),
595
+ Time.parse('Thu Jan 15 06:00:00 PST 1998')
596
+ ])
597
+ end
598
+
599
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=10;BYMONTHDAY=1,-1' do
600
+ rrule = 'FREQ=MONTHLY;COUNT=10;BYMONTHDAY=1,-1'
601
+ dtstart = Time.parse('Tue Sep 30 06:00:00 PDT 1997')
602
+ timezone = 'America/New_York'
603
+
604
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
605
+ expect(rrule.all).to match_array([
606
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
607
+ Time.parse('Wed Oct 1 06:00:00 PDT 1997'),
608
+ Time.parse('Fri Oct 31 06:00:00 PST 1997'),
609
+ Time.parse('Sat Nov 1 06:00:00 PST 1997'),
610
+ Time.parse('Sun Nov 30 06:00:00 PST 1997'),
611
+ Time.parse('Mon Dec 1 06:00:00 PST 1997'),
612
+ Time.parse('Wed Dec 31 06:00:00 PST 1997'),
613
+ Time.parse('Thu Jan 1 06:00:00 PST 1998'),
614
+ Time.parse('Sat Jan 31 06:00:00 PST 1998'),
615
+ Time.parse('Sun Feb 1 06:00:00 PST 1998')
616
+ ])
617
+ end
618
+
619
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;INTERVAL=18;COUNT=10;BYMONTHDAY=10,11,12,13,14,15' do
620
+ rrule = 'FREQ=MONTHLY;INTERVAL=18;COUNT=10;BYMONTHDAY=10,11,12,13,14,15'
621
+ dtstart = Time.parse('Wed Sep 10 06:00:00 PDT 1997')
622
+ timezone = 'America/New_York'
623
+
624
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
625
+ expect(rrule.all).to match_array([
626
+ Time.parse('Wed Sep 10 06:00:00 PDT 1997'),
627
+ Time.parse('Thu Sep 11 06:00:00 PDT 1997'),
628
+ Time.parse('Fri Sep 12 06:00:00 PDT 1997'),
629
+ Time.parse('Sat Sep 13 06:00:00 PDT 1997'),
630
+ Time.parse('Sun Sep 14 06:00:00 PDT 1997'),
631
+ Time.parse('Mon Sep 15 06:00:00 PDT 1997'),
632
+ Time.parse('Wed Mar 10 06:00:00 PST 1999'),
633
+ Time.parse('Thu Mar 11 06:00:00 PST 1999'),
634
+ Time.parse('Fri Mar 12 06:00:00 PST 1999'),
635
+ Time.parse('Sat Mar 13 06:00:00 PST 1999')
636
+ ])
637
+ end
638
+
639
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=10;BYMONTH=6,7' do
640
+ rrule = 'FREQ=YEARLY;COUNT=10;BYMONTH=6,7'
641
+ dtstart = Time.parse('Tue Jun 10 06:00:00 PDT 1997')
642
+ timezone = 'America/New_York'
643
+
644
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
645
+ expect(rrule.all).to match_array([
646
+ Time.parse('Tue Jun 10 06:00:00 PDT 1997'),
647
+ Time.parse('Thu Jul 10 06:00:00 PDT 1997'),
648
+ Time.parse('Wed Jun 10 06:00:00 PDT 1998'),
649
+ Time.parse('Fri Jul 10 06:00:00 PDT 1998'),
650
+ Time.parse('Thu Jun 10 06:00:00 PDT 1999'),
651
+ Time.parse('Sat Jul 10 06:00:00 PDT 1999'),
652
+ Time.parse('Sat Jun 10 06:00:00 PDT 2000'),
653
+ Time.parse('Mon Jul 10 06:00:00 PDT 2000'),
654
+ Time.parse('Sun Jun 10 06:00:00 PDT 2001'),
655
+ Time.parse('Tue Jul 10 06:00:00 PDT 2001')
656
+ ])
657
+ end
658
+
659
+ it 'returns the correct result with an rrule of FREQ=YEARLY;INTERVAL=2;COUNT=10;BYMONTH=1,2,3' do
660
+ rrule = 'FREQ=YEARLY;INTERVAL=2;COUNT=10;BYMONTH=1,2,3'
661
+ dtstart = Time.parse('Mon Mar 10 06:00:00 PST 1997')
662
+ timezone = 'America/New_York'
663
+
664
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
665
+ expect(rrule.all).to match_array([
666
+ Time.parse('Mon Mar 10 06:00:00 PST 1997'),
667
+ Time.parse('Sun Jan 10 06:00:00 PST 1999'),
668
+ Time.parse('Wed Feb 10 06:00:00 PST 1999'),
669
+ Time.parse('Wed Mar 10 06:00:00 PST 1999'),
670
+ Time.parse('Wed Jan 10 06:00:00 PST 2001'),
671
+ Time.parse('Sat Feb 10 06:00:00 PST 2001'),
672
+ Time.parse('Sat Mar 10 06:00:00 PST 2001'),
673
+ Time.parse('Fri Jan 10 06:00:00 PST 2003'),
674
+ Time.parse('Mon Feb 10 06:00:00 PST 2003'),
675
+ Time.parse('Mon Mar 10 06:00:00 PST 2003')
676
+ ])
677
+ end
678
+
679
+ it 'returns the correct result with an rrule of FREQ=YEARLY;INTERVAL=3;COUNT=10;BYYEARDAY=1,100,200' do
680
+ rrule = 'FREQ=YEARLY;INTERVAL=3;COUNT=10;BYYEARDAY=1,100,200'
681
+ dtstart = Time.parse('Wed Jan 1 06:00:00 PST 1997')
682
+ timezone = 'America/New_York'
683
+
684
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
685
+ expect(rrule.all).to match_array([
686
+ Time.parse('Wed Jan 1 06:00:00 PST 1997'),
687
+ Time.parse('Thu Apr 10 06:00:00 PDT 1997'),
688
+ Time.parse('Sat Jul 19 06:00:00 PDT 1997'),
689
+ Time.parse('Sat Jan 1 06:00:00 PST 2000'),
690
+ Time.parse('Sun Apr 9 06:00:00 PDT 2000'),
691
+ Time.parse('Tue Jul 18 06:00:00 PDT 2000'),
692
+ Time.parse('Wed Jan 1 06:00:00 PST 2003'),
693
+ Time.parse('Thu Apr 10 06:00:00 PDT 2003'),
694
+ Time.parse('Sat Jul 19 06:00:00 PDT 2003'),
695
+ Time.parse('Sun Jan 1 06:00:00 PST 2006')
696
+ ])
697
+ end
698
+
699
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13;COUNT=6' do
700
+ rrule = 'FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13;COUNT=6'
701
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
702
+ timezone = 'America/New_York'
703
+
704
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
705
+ expect(rrule.all).to match_array([
706
+ Time.parse('Fri Feb 13 06:00:00 PST 1998'),
707
+ Time.parse('Fri Mar 13 06:00:00 PST 1998'),
708
+ Time.parse('Fri Nov 13 06:00:00 PST 1998'),
709
+ Time.parse('Fri Aug 13 06:00:00 PDT 1999'),
710
+ Time.parse('Fri Oct 13 06:00:00 PDT 2000'),
711
+ Time.parse('Fri Apr 13 06:00:00 PDT 2001')
712
+ ])
713
+ end
714
+
715
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3' do
716
+ rrule = 'FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3'
717
+ dtstart = Time.parse('Thu Sep 4 06:00:00 PDT 1997')
718
+ timezone = 'America/New_York'
719
+
720
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
721
+ expect(rrule.all).to match_array([
722
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
723
+ Time.parse('Tue Oct 7 06:00:00 PDT 1997'),
724
+ Time.parse('Thu Nov 6 06:00:00 PST 1997')
725
+ ])
726
+ end
727
+
728
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO' do
729
+ rrule = 'FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO'
730
+ dtstart = Time.parse('Tue Aug 5 06:00:00 PDT 1997')
731
+ timezone = 'America/New_York'
732
+
733
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
734
+ expect(rrule.all).to match_array([
735
+ Time.parse('Tue Aug 5 06:00:00 PDT 1997'),
736
+ Time.parse('Sun Aug 10 06:00:00 PDT 1997'),
737
+ Time.parse('Tue Aug 19 06:00:00 PDT 1997'),
738
+ Time.parse('Sun Aug 24 06:00:00 PDT 1997')
739
+ ])
740
+ end
741
+
742
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU' do
743
+ rrule = 'FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU'
744
+ dtstart = Time.parse('Tue Aug 5 06:00:00 PDT 1997')
745
+ timezone = 'America/New_York'
746
+
747
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
748
+ expect(rrule.all).to match_array([
749
+ Time.parse('Tue Aug 5 06:00:00 PDT 1997'),
750
+ Time.parse('Sun Aug 17 06:00:00 PDT 1997'),
751
+ Time.parse('Tue Aug 19 06:00:00 PDT 1997'),
752
+ Time.parse('Sun Aug 31 06:00:00 PDT 1997')
753
+ ])
754
+ end
755
+
756
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTHDAY=15,30;COUNT=5' do
757
+ rrule = 'FREQ=MONTHLY;BYMONTHDAY=15,30;COUNT=5'
758
+ dtstart = Time.parse('Mon Jan 15 06:00:00 PST 2007')
759
+ timezone = 'America/New_York'
760
+
761
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
762
+ expect(rrule.all).to match_array([
763
+ Time.parse('Mon Jan 15 06:00:00 PST 2007'),
764
+ Time.parse('Tue Jan 30 06:00:00 PST 2007'),
765
+ Time.parse('Thu Feb 15 06:00:00 PST 2007'),
766
+ Time.parse('Thu Mar 15 06:00:00 PDT 2007'),
767
+ Time.parse('Fri Mar 30 06:00:00 PDT 2007')
768
+ ])
769
+ end
770
+
771
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=3' do
772
+ rrule = 'FREQ=DAILY;COUNT=3'
773
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
774
+ timezone = 'America/Los_Angeles'
775
+
776
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
777
+ expect(rrule.all).to match_array([
778
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
779
+ Time.parse('Wed Sep 3 09:00:00 PDT 1997'),
780
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997')
781
+ ])
782
+ end
783
+
784
+ it 'returns the correct result with an rrule of FREQ=DAILY;BYMONTH=1,3;COUNT=4' do
785
+ rrule = 'FREQ=DAILY;BYMONTH=1,3;COUNT=4'
786
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
787
+ timezone = 'America/Los_Angeles'
788
+
789
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
790
+ expect(rrule.all).to match_array([
791
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
792
+ Time.parse('Fri Jan 2 09:00:00 PST 1998'),
793
+ Time.parse('Sat Jan 3 09:00:00 PST 1998'),
794
+ Time.parse('Sun Jan 4 09:00:00 PST 1998')
795
+ ])
796
+ end
797
+
798
+ it 'returns the correct result with an rrule of FREQ=DAILY;BYMONTH=1,3;COUNT=4;BYMONTHDAY=5,7' do
799
+ rrule = 'FREQ=DAILY;BYMONTH=1,3;COUNT=4;BYMONTHDAY=5,7'
800
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
801
+ timezone = 'America/Los_Angeles'
802
+
803
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
804
+ expect(rrule.all).to match_array([
805
+ Time.parse('Mon Jan 5 09:00:00 PST 1998'),
806
+ Time.parse('Wed Jan 7 09:00:00 PST 1998'),
807
+ Time.parse('Thu Mar 5 09:00:00 PST 1998'),
808
+ Time.parse('Sat Mar 7 09:00:00 PST 1998')
809
+ ])
810
+ end
811
+
812
+ it 'returns the correct result with an rrule of FREQ=DAILY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3' do
813
+ rrule = 'FREQ=DAILY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3'
814
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
815
+ timezone = 'America/Los_Angeles'
816
+
817
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
818
+ expect(rrule.all).to match_array([
819
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
820
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
821
+ Time.parse('Thu Mar 1 09:00:00 PST 2001'),
822
+ Time.parse('Tue Jan 1 09:00:00 PST 2002')
823
+ ])
824
+ end
825
+
826
+ it 'returns the correct result with an rrule of FREQ=DAILY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH' do
827
+ rrule = 'FREQ=DAILY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH'
828
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
829
+ timezone = 'America/Los_Angeles'
830
+
831
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
832
+ expect(rrule.all).to match_array([
833
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
834
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
835
+ Time.parse('Thu Jan 8 09:00:00 PST 1998'),
836
+ Time.parse('Tue Jan 13 09:00:00 PST 1998')
837
+ ])
838
+ end
839
+
840
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=4;BYMONTHDAY=1,3' do
841
+ rrule = 'FREQ=DAILY;COUNT=4;BYMONTHDAY=1,3'
842
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
843
+ timezone = 'America/Los_Angeles'
844
+
845
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
846
+ expect(rrule.all).to match_array([
847
+ Time.parse('Wed Sep 3 09:00:00 PDT 1997'),
848
+ Time.parse('Wed Oct 1 09:00:00 PDT 1997'),
849
+ Time.parse('Fri Oct 3 09:00:00 PDT 1997'),
850
+ Time.parse('Sat Nov 1 09:00:00 PST 1997')
851
+ ])
852
+ end
853
+
854
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3' do
855
+ rrule = 'FREQ=DAILY;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3'
856
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
857
+ timezone = 'America/Los_Angeles'
858
+
859
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
860
+ expect(rrule.all).to match_array([
861
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
862
+ Time.parse('Tue Feb 3 09:00:00 PST 1998'),
863
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
864
+ Time.parse('Tue Sep 1 09:00:00 PDT 1998')
865
+ ])
866
+ end
867
+
868
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=3;BYDAY=TU,TH' do
869
+ rrule = 'FREQ=DAILY;COUNT=3;BYDAY=TU,TH'
870
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
871
+ timezone = 'America/Los_Angeles'
872
+
873
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
874
+ expect(rrule.all).to match_array([
875
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
876
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997'),
877
+ Time.parse('Tue Sep 9 09:00:00 PDT 1997')
878
+ ])
879
+ end
880
+
881
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=3;INTERVAL=2' do
882
+ rrule = 'FREQ=DAILY;COUNT=3;INTERVAL=2'
883
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
884
+ timezone = 'America/Los_Angeles'
885
+
886
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
887
+ expect(rrule.all).to match_array([
888
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
889
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997'),
890
+ Time.parse('Sat Sep 6 09:00:00 PDT 1997')
891
+ ])
892
+ end
893
+
894
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=3;INTERVAL=92' do
895
+ rrule = 'FREQ=DAILY;COUNT=3;INTERVAL=92'
896
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
897
+ timezone = 'America/Los_Angeles'
898
+
899
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
900
+ expect(rrule.all).to match_array([
901
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
902
+ Time.parse('Wed Dec 3 09:00:00 PST 1997'),
903
+ Time.parse('Thu Mar 5 09:00:00 PST 1998')
904
+ ])
905
+ end
906
+
907
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=2;COUNT=1;BYMONTHDAY=31' do
908
+ rrule = 'FREQ=YEARLY;BYMONTH=2;COUNT=1;BYMONTHDAY=31'
909
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 9997')
910
+ timezone = 'America/Los_Angeles'
911
+
912
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
913
+ expect(rrule.all).to be_empty
914
+ end
915
+
916
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=3' do
917
+ rrule = 'FREQ=MONTHLY;COUNT=3'
918
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
919
+ timezone = 'America/Los_Angeles'
920
+
921
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
922
+ expect(rrule.all).to match_array([
923
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
924
+ Time.parse('Thu Oct 2 09:00:00 PDT 1997'),
925
+ Time.parse('Sun Nov 2 09:00:00 PST 1997')
926
+ ])
927
+ end
928
+
929
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTH=1,3;COUNT=4' do
930
+ rrule = 'FREQ=MONTHLY;BYMONTH=1,3;COUNT=4'
931
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
932
+ timezone = 'America/Los_Angeles'
933
+
934
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
935
+ expect(rrule.all).to match_array([
936
+ Time.parse('Fri Jan 2 09:00:00 PST 1998'),
937
+ Time.parse('Mon Mar 2 09:00:00 PST 1998'),
938
+ Time.parse('Sat Jan 2 09:00:00 PST 1999'),
939
+ Time.parse('Tue Mar 2 09:00:00 PST 1999')
940
+ ])
941
+ end
942
+
943
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYMONTHDAY=5,7' do
944
+ rrule = 'FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYMONTHDAY=5,7'
945
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
946
+ timezone = 'America/Los_Angeles'
947
+
948
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
949
+ expect(rrule.all).to match_array([
950
+ Time.parse('Mon Jan 5 09:00:00 PST 1998'),
951
+ Time.parse('Wed Jan 7 09:00:00 PST 1998'),
952
+ Time.parse('Thu Mar 5 09:00:00 PST 1998'),
953
+ Time.parse('Sat Mar 7 09:00:00 PST 1998')
954
+ ])
955
+ end
956
+
957
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3' do
958
+ rrule = 'FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3'
959
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
960
+ timezone = 'America/Los_Angeles'
961
+
962
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
963
+ expect(rrule.all).to match_array([
964
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
965
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
966
+ Time.parse('Thu Mar 1 09:00:00 PST 2001'),
967
+ Time.parse('Tue Jan 1 09:00:00 PST 2002')
968
+ ])
969
+ end
970
+
971
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=1TU,-1TH' do
972
+ rrule = 'FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=1TU,-1TH'
973
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
974
+ timezone = 'America/Los_Angeles'
975
+
976
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
977
+ expect(rrule.all).to match_array([
978
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
979
+ Time.parse('Thu Jan 29 09:00:00 PST 1998'),
980
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
981
+ Time.parse('Thu Mar 26 09:00:00 PST 1998')
982
+ ])
983
+ end
984
+
985
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=3TU,-3TH' do
986
+ rrule = 'FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=3TU,-3TH'
987
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
988
+ timezone = 'America/Los_Angeles'
989
+
990
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
991
+ expect(rrule.all).to match_array([
992
+ Time.parse('Thu Jan 15 09:00:00 PST 1998'),
993
+ Time.parse('Tue Jan 20 09:00:00 PST 1998'),
994
+ Time.parse('Thu Mar 12 09:00:00 PST 1998'),
995
+ Time.parse('Tue Mar 17 09:00:00 PST 1998')
996
+ ])
997
+ end
998
+
999
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH' do
1000
+ rrule = 'FREQ=MONTHLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH'
1001
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1002
+ timezone = 'America/Los_Angeles'
1003
+
1004
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1005
+ expect(rrule.all).to match_array([
1006
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1007
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
1008
+ Time.parse('Thu Jan 8 09:00:00 PST 1998'),
1009
+ Time.parse('Tue Jan 13 09:00:00 PST 1998')
1010
+ ])
1011
+ end
1012
+
1013
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=4;BYMONTHDAY=1,3' do
1014
+ rrule = 'FREQ=MONTHLY;COUNT=4;BYMONTHDAY=1,3'
1015
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1016
+ timezone = 'America/Los_Angeles'
1017
+
1018
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1019
+ expect(rrule.all).to match_array([
1020
+ Time.parse('Wed Sep 3 09:00:00 PDT 1997'),
1021
+ Time.parse('Wed Oct 1 09:00:00 PDT 1997'),
1022
+ Time.parse('Fri Oct 3 09:00:00 PDT 1997'),
1023
+ Time.parse('Sat Nov 1 09:00:00 PST 1997')
1024
+ ])
1025
+ end
1026
+
1027
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3' do
1028
+ rrule = 'FREQ=MONTHLY;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3'
1029
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1030
+ timezone = 'America/Los_Angeles'
1031
+
1032
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1033
+ expect(rrule.all).to match_array([
1034
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1035
+ Time.parse('Tue Feb 3 09:00:00 PST 1998'),
1036
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
1037
+ Time.parse('Tue Sep 1 09:00:00 PDT 1998')
1038
+ ])
1039
+ end
1040
+
1041
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=3;BYDAY=1TU,-1TH' do
1042
+ rrule = 'FREQ=MONTHLY;COUNT=3;BYDAY=1TU,-1TH'
1043
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1044
+ timezone = 'America/Los_Angeles'
1045
+
1046
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1047
+ expect(rrule.all).to match_array([
1048
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1049
+ Time.parse('Thu Sep 25 09:00:00 PDT 1997'),
1050
+ Time.parse('Tue Oct 7 09:00:00 PDT 1997')
1051
+ ])
1052
+ end
1053
+
1054
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=4;BYDAY=3TU,-3TH' do
1055
+ rrule = 'FREQ=MONTHLY;COUNT=4;BYDAY=3TU,-3TH'
1056
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1057
+ timezone = 'America/Los_Angeles'
1058
+
1059
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1060
+ expect(rrule.all).to match_array([
1061
+ Time.parse('Thu Sep 11 09:00:00 PDT 1997'),
1062
+ Time.parse('Tue Sep 16 09:00:00 PDT 1997'),
1063
+ Time.parse('Thu Oct 16 09:00:00 PDT 1997'),
1064
+ Time.parse('Tue Oct 21 09:00:00 PDT 1997')
1065
+ ])
1066
+ end
1067
+
1068
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=3;BYDAY=TU,TH' do
1069
+ rrule = 'FREQ=MONTHLY;COUNT=3;BYDAY=TU,TH'
1070
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1071
+ timezone = 'America/Los_Angeles'
1072
+
1073
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1074
+ expect(rrule.all).to match_array([
1075
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1076
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997'),
1077
+ Time.parse('Tue Sep 9 09:00:00 PDT 1997')
1078
+ ])
1079
+ end
1080
+
1081
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=3;INTERVAL=2' do
1082
+ rrule = 'FREQ=MONTHLY;COUNT=3;INTERVAL=2'
1083
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1084
+ timezone = 'America/Los_Angeles'
1085
+
1086
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1087
+ expect(rrule.all).to match_array([
1088
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1089
+ Time.parse('Sun Nov 2 09:00:00 PST 1997'),
1090
+ Time.parse('Fri Jan 2 09:00:00 PST 1998')
1091
+ ])
1092
+ end
1093
+
1094
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;COUNT=3;INTERVAL=18' do
1095
+ rrule = 'FREQ=MONTHLY;COUNT=3;INTERVAL=18'
1096
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1097
+ timezone = 'America/Los_Angeles'
1098
+
1099
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1100
+ expect(rrule.all).to match_array([
1101
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1102
+ Time.parse('Tue Mar 2 09:00:00 PST 1999'),
1103
+ Time.parse('Sat Sep 2 09:00:00 PDT 2000')
1104
+ ])
1105
+ end
1106
+
1107
+ it 'returns the correct result with an rrule of FREQ=DAILY;UNTIL=19970901T170000Z' do
1108
+ rrule = 'FREQ=DAILY;UNTIL=19970901T170000Z'
1109
+ dtstart = Time.parse('Mon Sep 1 10:00:00 PDT 1997')
1110
+ timezone = 'America/Los_Angeles'
1111
+
1112
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1113
+ expect(rrule.all).to match_array([
1114
+ Time.parse('Mon Sep 1 10:00:00 PDT 1997')
1115
+ ])
1116
+ end
1117
+
1118
+ it 'returns the correct result with an rrule of FREQ=DAILY;UNTIL=19970904T160000Z' do
1119
+ rrule = 'FREQ=DAILY;UNTIL=19970904T160000Z'
1120
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1121
+ timezone = 'America/Los_Angeles'
1122
+
1123
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1124
+ expect(rrule.all).to match_array([
1125
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1126
+ Time.parse('Wed Sep 3 09:00:00 PDT 1997'),
1127
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997')
1128
+ ])
1129
+ end
1130
+
1131
+ it 'returns the correct result with an rrule of FREQ=DAILY;UNTIL=19970905T150000Z' do
1132
+ rrule = 'FREQ=DAILY;UNTIL=19970905T150000Z'
1133
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1134
+ timezone = 'America/Los_Angeles'
1135
+
1136
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1137
+ expect(rrule.all).to match_array([
1138
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1139
+ Time.parse('Wed Sep 3 09:00:00 PDT 1997'),
1140
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997')
1141
+ ])
1142
+ end
1143
+
1144
+ it 'returns the correct result with an rrule of FREQ=DAILY;UNTIL=19970902T160000Z' do
1145
+ rrule = 'FREQ=DAILY;UNTIL=19970902T160000Z'
1146
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1147
+ timezone = 'America/Los_Angeles'
1148
+
1149
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1150
+ expect(rrule.all).to match_array([
1151
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1152
+ ])
1153
+ end
1154
+
1155
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=3' do
1156
+ rrule = 'FREQ=WEEKLY;COUNT=3'
1157
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1158
+ timezone = 'America/Los_Angeles'
1159
+
1160
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1161
+ expect(rrule.all).to match_array([
1162
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1163
+ Time.parse('Tue Sep 9 09:00:00 PDT 1997'),
1164
+ Time.parse('Tue Sep 16 09:00:00 PDT 1997')
1165
+ ])
1166
+ end
1167
+
1168
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;BYMONTH=1,3;COUNT=4' do
1169
+ rrule = 'FREQ=WEEKLY;BYMONTH=1,3;COUNT=4'
1170
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1171
+ timezone = 'America/Los_Angeles'
1172
+
1173
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1174
+ expect(rrule.all).to match_array([
1175
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
1176
+ Time.parse('Tue Jan 13 09:00:00 PST 1998'),
1177
+ Time.parse('Tue Jan 20 09:00:00 PST 1998'),
1178
+ Time.parse('Tue Jan 27 09:00:00 PST 1998')
1179
+ ])
1180
+ end
1181
+
1182
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH' do
1183
+ rrule = 'FREQ=WEEKLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH'
1184
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1185
+ timezone = 'America/Los_Angeles'
1186
+
1187
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1188
+ expect(rrule.all).to match_array([
1189
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1190
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
1191
+ Time.parse('Thu Jan 8 09:00:00 PST 1998'),
1192
+ Time.parse('Tue Jan 13 09:00:00 PST 1998')
1193
+ ])
1194
+ end
1195
+
1196
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=3;BYDAY=TU,TH' do
1197
+ rrule = 'FREQ=WEEKLY;COUNT=3;BYDAY=TU,TH'
1198
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1199
+ timezone = 'America/Los_Angeles'
1200
+
1201
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1202
+ expect(rrule.all).to match_array([
1203
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1204
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997'),
1205
+ Time.parse('Tue Sep 9 09:00:00 PDT 1997')
1206
+ ])
1207
+ end
1208
+
1209
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=3;INTERVAL=2' do
1210
+ rrule = 'FREQ=WEEKLY;COUNT=3;INTERVAL=2'
1211
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1212
+ timezone = 'America/Los_Angeles'
1213
+
1214
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1215
+ expect(rrule.all).to match_array([
1216
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1217
+ Time.parse('Tue Sep 16 09:00:00 PDT 1997'),
1218
+ Time.parse('Tue Sep 30 09:00:00 PDT 1997')
1219
+ ])
1220
+ end
1221
+
1222
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=3;INTERVAL=20' do
1223
+ rrule = 'FREQ=WEEKLY;COUNT=3;INTERVAL=20'
1224
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1225
+ timezone = 'America/Los_Angeles'
1226
+
1227
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1228
+ expect(rrule.all).to match_array([
1229
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1230
+ Time.parse('Tue Jan 20 09:00:00 PST 1998'),
1231
+ Time.parse('Tue Jun 9 09:00:00 PDT 1998')
1232
+ ])
1233
+ end
1234
+
1235
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=3;BYDAY=TU,SU;WKST=MO;INTERVAL=2' do
1236
+ rrule = 'FREQ=WEEKLY;COUNT=3;BYDAY=TU,SU;WKST=MO;INTERVAL=2'
1237
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1238
+ timezone = 'America/Los_Angeles'
1239
+
1240
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1241
+ expect(rrule.all).to match_array([
1242
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1243
+ Time.parse('Sun Sep 7 09:00:00 PDT 1997'),
1244
+ Time.parse('Tue Sep 16 09:00:00 PDT 1997')
1245
+ ])
1246
+ end
1247
+
1248
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;COUNT=3;BYDAY=TU,SU;WKST=SU;INTERVAL=2' do
1249
+ rrule = 'FREQ=WEEKLY;COUNT=3;BYDAY=TU,SU;WKST=SU;INTERVAL=2'
1250
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1251
+ timezone = 'America/Los_Angeles'
1252
+
1253
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1254
+ expect(rrule.all).to match_array([
1255
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1256
+ Time.parse('Sun Sep 14 09:00:00 PDT 1997'),
1257
+ Time.parse('Tue Sep 16 09:00:00 PDT 1997')
1258
+ ])
1259
+ end
1260
+
1261
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=3' do
1262
+ rrule = 'FREQ=YEARLY;COUNT=3'
1263
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1264
+ timezone = 'America/Los_Angeles'
1265
+
1266
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1267
+ expect(rrule.all).to match_array([
1268
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1269
+ Time.parse('Wed Sep 2 09:00:00 PDT 1998'),
1270
+ Time.parse('Thu Sep 2 09:00:00 PDT 1999')
1271
+ ])
1272
+ end
1273
+
1274
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=1,3;COUNT=4' do
1275
+ rrule = 'FREQ=YEARLY;BYMONTH=1,3;COUNT=4'
1276
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1277
+ timezone = 'America/Los_Angeles'
1278
+
1279
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1280
+ expect(rrule.all).to match_array([
1281
+ Time.parse('Fri Jan 2 09:00:00 PST 1998'),
1282
+ Time.parse('Mon Mar 2 09:00:00 PST 1998'),
1283
+ Time.parse('Sat Jan 2 09:00:00 PST 1999'),
1284
+ Time.parse('Tue Mar 2 09:00:00 PST 1999')
1285
+ ])
1286
+ end
1287
+
1288
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYMONTHDAY=5,7' do
1289
+ rrule = 'FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYMONTHDAY=5,7'
1290
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1291
+ timezone = 'America/Los_Angeles'
1292
+
1293
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1294
+ expect(rrule.all).to match_array([
1295
+ Time.parse('Mon Jan 5 09:00:00 PST 1998'),
1296
+ Time.parse('Wed Jan 7 09:00:00 PST 1998'),
1297
+ Time.parse('Thu Mar 5 09:00:00 PST 1998'),
1298
+ Time.parse('Sat Mar 7 09:00:00 PST 1998')
1299
+ ])
1300
+ end
1301
+
1302
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3' do
1303
+ rrule = 'FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3'
1304
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1305
+ timezone = 'America/Los_Angeles'
1306
+
1307
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1308
+ expect(rrule.all).to match_array([
1309
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1310
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
1311
+ Time.parse('Thu Mar 1 09:00:00 PST 2001'),
1312
+ Time.parse('Tue Jan 1 09:00:00 PST 2002')
1313
+ ])
1314
+ end
1315
+
1316
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=1TU,-1TH' do
1317
+ rrule = 'FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=1TU,-1TH'
1318
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1319
+ timezone = 'America/Los_Angeles'
1320
+
1321
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1322
+ expect(rrule.all).to match_array([
1323
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
1324
+ Time.parse('Thu Jan 29 09:00:00 PST 1998'),
1325
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
1326
+ Time.parse('Thu Mar 26 09:00:00 PST 1998')
1327
+ ])
1328
+ end
1329
+
1330
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=3TU,-3TH' do
1331
+ rrule = 'FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=3TU,-3TH'
1332
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1333
+ timezone = 'America/Los_Angeles'
1334
+
1335
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1336
+ expect(rrule.all).to match_array([
1337
+ Time.parse('Thu Jan 15 09:00:00 PST 1998'),
1338
+ Time.parse('Tue Jan 20 09:00:00 PST 1998'),
1339
+ Time.parse('Thu Mar 12 09:00:00 PST 1998'),
1340
+ Time.parse('Tue Mar 17 09:00:00 PST 1998')
1341
+ ])
1342
+ end
1343
+
1344
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH' do
1345
+ rrule = 'FREQ=YEARLY;BYMONTH=1,3;COUNT=4;BYDAY=TU,TH'
1346
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1347
+ timezone = 'America/Los_Angeles'
1348
+
1349
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1350
+ expect(rrule.all).to match_array([
1351
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1352
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
1353
+ Time.parse('Thu Jan 8 09:00:00 PST 1998'),
1354
+ Time.parse('Tue Jan 13 09:00:00 PST 1998')
1355
+ ])
1356
+ end
1357
+
1358
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYMONTHDAY=1,3' do
1359
+ rrule = 'FREQ=YEARLY;COUNT=4;BYMONTHDAY=1,3'
1360
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1361
+ timezone = 'America/Los_Angeles'
1362
+
1363
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1364
+ expect(rrule.all).to match_array([
1365
+ Time.parse('Wed Sep 3 09:00:00 PDT 1997'),
1366
+ Time.parse('Wed Oct 1 09:00:00 PDT 1997'),
1367
+ Time.parse('Fri Oct 3 09:00:00 PDT 1997'),
1368
+ Time.parse('Sat Nov 1 09:00:00 PST 1997')
1369
+ ])
1370
+ end
1371
+
1372
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3' do
1373
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=TU,TH;BYMONTHDAY=1,3'
1374
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1375
+ timezone = 'America/Los_Angeles'
1376
+
1377
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1378
+ expect(rrule.all).to match_array([
1379
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1380
+ Time.parse('Tue Feb 3 09:00:00 PST 1998'),
1381
+ Time.parse('Tue Mar 3 09:00:00 PST 1998'),
1382
+ Time.parse('Tue Sep 1 09:00:00 PDT 1998')
1383
+ ])
1384
+ end
1385
+
1386
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=1TU,-1TH' do
1387
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=1TU,-1TH'
1388
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1389
+ timezone = 'America/Los_Angeles'
1390
+
1391
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1392
+ expect(rrule.all).to match_array([
1393
+ Time.parse('Thu Dec 25 09:00:00 PST 1997'),
1394
+ Time.parse('Tue Jan 6 09:00:00 PST 1998'),
1395
+ Time.parse('Thu Dec 31 09:00:00 PST 1998'),
1396
+ Time.parse('Tue Jan 5 09:00:00 PST 1999')
1397
+ ])
1398
+ end
1399
+
1400
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=3TU,-3TH' do
1401
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=3TU,-3TH'
1402
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1403
+ timezone = 'America/Los_Angeles'
1404
+
1405
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1406
+ expect(rrule.all).to match_array([
1407
+ Time.parse('Thu Dec 11 09:00:00 PST 1997'),
1408
+ Time.parse('Tue Jan 20 09:00:00 PST 1998'),
1409
+ Time.parse('Thu Dec 17 09:00:00 PST 1998'),
1410
+ Time.parse('Tue Jan 19 09:00:00 PST 1999')
1411
+ ])
1412
+ end
1413
+
1414
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=3;BYDAY=TU,TH' do
1415
+ rrule = 'FREQ=YEARLY;COUNT=3;BYDAY=TU,TH'
1416
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1417
+ timezone = 'America/Los_Angeles'
1418
+
1419
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1420
+ expect(rrule.all).to match_array([
1421
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1422
+ Time.parse('Thu Sep 4 09:00:00 PDT 1997'),
1423
+ Time.parse('Tue Sep 9 09:00:00 PDT 1997')
1424
+ ])
1425
+ end
1426
+
1427
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYWEEKNO=20' do
1428
+ rrule = 'FREQ=YEARLY;COUNT=4;BYWEEKNO=20'
1429
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1430
+ timezone = 'America/Los_Angeles'
1431
+
1432
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1433
+ expect(rrule.all).to match_array([
1434
+ Time.parse('Mon May 11 09:00:00 PDT 1998'),
1435
+ Time.parse('Tue May 12 09:00:00 PDT 1998'),
1436
+ Time.parse('Wed May 13 09:00:00 PDT 1998'),
1437
+ Time.parse('Thu May 14 09:00:00 PDT 1998')
1438
+ ])
1439
+ end
1440
+
1441
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=MO;BYWEEKNO=1' do
1442
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=MO;BYWEEKNO=1'
1443
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1444
+ timezone = 'America/Los_Angeles'
1445
+
1446
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1447
+ expect(rrule.all).to match_array([
1448
+ Time.parse('Mon Dec 29 09:00:00 PST 1997'),
1449
+ Time.parse('Mon Jan 4 09:00:00 PST 1999'),
1450
+ Time.parse('Mon Jan 3 09:00:00 PST 2000'),
1451
+ Time.parse('Mon Jan 1 09:00:00 PST 2001')
1452
+ ])
1453
+ end
1454
+
1455
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=MO;BYWEEKNO=53' do
1456
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=MO;BYWEEKNO=53'
1457
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1458
+ timezone = 'America/Los_Angeles'
1459
+
1460
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1461
+ expect(rrule.all).to match_array([
1462
+ Time.parse('Mon Dec 28 09:00:00 PST 1998'),
1463
+ Time.parse('Mon Dec 27 09:00:00 PST 2004'),
1464
+ Time.parse('Mon Dec 28 09:00:00 PST 2009'),
1465
+ Time.parse('Mon Dec 28 09:00:00 PST 2015')
1466
+ ])
1467
+ end
1468
+
1469
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=SU;BYWEEKNO=52' do
1470
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=SU;BYWEEKNO=52'
1471
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1472
+ timezone = 'America/Los_Angeles'
1473
+
1474
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1475
+ expect(rrule.all).to match_array([
1476
+ Time.parse('Sun Dec 28 09:00:00 PST 1997'),
1477
+ Time.parse('Sun Dec 27 09:00:00 PST 1998'),
1478
+ Time.parse('Sun Jan 2 09:00:00 PST 2000'),
1479
+ Time.parse('Sun Dec 31 09:00:00 PST 2000')
1480
+ ])
1481
+ end
1482
+
1483
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=4;BYDAY=SU;BYWEEKNO=-1' do
1484
+ rrule = 'FREQ=YEARLY;COUNT=4;BYDAY=SU;BYWEEKNO=-1'
1485
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1486
+ timezone = 'America/Los_Angeles'
1487
+
1488
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1489
+ expect(rrule.all).to match_array([
1490
+ Time.parse('Sun Dec 28 09:00:00 PST 1997'),
1491
+ Time.parse('Sun Jan 3 09:00:00 PST 1999'),
1492
+ Time.parse('Sun Jan 2 09:00:00 PST 2000'),
1493
+ Time.parse('Sun Dec 31 09:00:00 PST 2000')
1494
+ ])
1495
+ end
1496
+
1497
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=5;BYYEARDAY=1,100,200,365' do
1498
+ rrule = 'FREQ=YEARLY;COUNT=5;BYYEARDAY=1,100,200,365'
1499
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1500
+ timezone = 'America/Los_Angeles'
1501
+
1502
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1503
+ expect(rrule.all).to match_array([
1504
+ Time.parse('Wed Dec 31 09:00:00 PST 1997'),
1505
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1506
+ Time.parse('Fri Apr 10 09:00:00 PDT 1998'),
1507
+ Time.parse('Sun Jul 19 09:00:00 PDT 1998'),
1508
+ Time.parse('Thu Dec 31 09:00:00 PST 1998')
1509
+ ])
1510
+ end
1511
+
1512
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=5;BYYEARDAY=-365,-266,-166,-1' do
1513
+ rrule = 'FREQ=YEARLY;COUNT=5;BYYEARDAY=-365,-266,-166,-1'
1514
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1515
+ timezone = 'America/Los_Angeles'
1516
+
1517
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1518
+ expect(rrule.all).to match_array([
1519
+ Time.parse('Wed Dec 31 09:00:00 PST 1997'),
1520
+ Time.parse('Thu Jan 1 09:00:00 PST 1998'),
1521
+ Time.parse('Fri Apr 10 09:00:00 PDT 1998'),
1522
+ Time.parse('Sun Jul 19 09:00:00 PDT 1998'),
1523
+ Time.parse('Thu Dec 31 09:00:00 PST 1998')
1524
+ ])
1525
+ end
1526
+
1527
+ it 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=3;INTERVAL=2' do
1528
+ rrule = 'FREQ=YEARLY;COUNT=3;INTERVAL=2'
1529
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1530
+ timezone = 'America/Los_Angeles'
1531
+
1532
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1533
+ expect(rrule.all).to match_array([
1534
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1535
+ Time.parse('Thu Sep 2 09:00:00 PDT 1999'),
1536
+ Time.parse('Sun Sep 2 09:00:00 PDT 2001')
1537
+ ])
1538
+ end
1539
+
1540
+ # Ruby's Time class only properly handles years up to 2038, and so gives an incorrect
1541
+ # offset for the last two occurrences here.
1542
+ xit 'returns the correct result with an rrule of FREQ=YEARLY;COUNT=3;INTERVAL=100' do
1543
+ rrule = 'FREQ=YEARLY;COUNT=3;INTERVAL=100'
1544
+ dtstart = Time.parse('Tue Sep 2 09:00:00 PDT 1997')
1545
+ timezone = 'America/Los_Angeles'
1546
+
1547
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1548
+ expect(rrule.all).to match_array([
1549
+ Time.parse('Tue Sep 2 09:00:00 PDT 1997'),
1550
+ Time.parse('Mon Sep 2 09:00:00 PDT 2097'),
1551
+ Time.parse('Sat Sep 2 09:00:00 PDT 2197')
1552
+ ])
1553
+ end
1554
+
1555
+ xit 'returns the correct result with an rrule of FREQ=YEARLY;INTERVAL=1;BYDAY=MO,-1TU;UNTIL=20160901T200000Z' do
1556
+ rrule = 'FREQ=YEARLY;INTERVAL=1;BYDAY=MO,-1TU;UNTIL=20160901T200000Z'
1557
+ dtstart = Time.parse('Mon Sep 1 19:00:00 PDT 2014')
1558
+ timezone = 'America/Los_Angeles'
1559
+
1560
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1561
+ expect(rrule.all).to match_array([
1562
+ Time.parse('Mon Sep 1 19:00:00 PDT 2014'),
1563
+ Time.parse('Mon Sep 8 19:00:00 PDT 2014'),
1564
+ Time.parse('Mon Sep 15 19:00:00 PDT 2014'),
1565
+ Time.parse('Mon Sep 22 19:00:00 PDT 2014'),
1566
+ Time.parse('Mon Sep 29 19:00:00 PDT 2014'),
1567
+ Time.parse('Mon Oct 6 19:00:00 PDT 2014'),
1568
+ Time.parse('Mon Oct 13 19:00:00 PDT 2014'),
1569
+ Time.parse('Mon Oct 20 19:00:00 PDT 2014'),
1570
+ Time.parse('Mon Oct 27 19:00:00 PDT 2014'),
1571
+ Time.parse('Mon Nov 3 19:00:00 PST 2014'),
1572
+ Time.parse('Mon Nov 10 19:00:00 PST 2014'),
1573
+ Time.parse('Mon Nov 17 19:00:00 PST 2014'),
1574
+ Time.parse('Mon Nov 24 19:00:00 PST 2014'),
1575
+ Time.parse('Mon Dec 1 19:00:00 PST 2014'),
1576
+ Time.parse('Mon Dec 8 19:00:00 PST 2014'),
1577
+ Time.parse('Mon Dec 15 19:00:00 PST 2014'),
1578
+ Time.parse('Mon Dec 22 19:00:00 PST 2014'),
1579
+ Time.parse('Mon Dec 29 19:00:00 PST 2014'),
1580
+ Time.parse('Tue Dec 30 19:00:00 PST 2014'),
1581
+ Time.parse('Mon Jan 5 19:00:00 PST 2015'),
1582
+ Time.parse('Mon Jan 12 19:00:00 PST 2015'),
1583
+ Time.parse('Mon Jan 19 19:00:00 PST 2015'),
1584
+ Time.parse('Mon Jan 26 19:00:00 PST 2015'),
1585
+ Time.parse('Mon Feb 2 19:00:00 PST 2015'),
1586
+ Time.parse('Mon Feb 9 19:00:00 PST 2015'),
1587
+ Time.parse('Mon Feb 16 19:00:00 PST 2015'),
1588
+ Time.parse('Mon Feb 23 19:00:00 PST 2015'),
1589
+ Time.parse('Mon Mar 2 19:00:00 PST 2015'),
1590
+ Time.parse('Mon Mar 9 19:00:00 PDT 2015'),
1591
+ Time.parse('Mon Mar 16 19:00:00 PDT 2015'),
1592
+ Time.parse('Mon Mar 23 19:00:00 PDT 2015'),
1593
+ Time.parse('Mon Mar 30 19:00:00 PDT 2015'),
1594
+ Time.parse('Mon Apr 6 19:00:00 PDT 2015'),
1595
+ Time.parse('Mon Apr 13 19:00:00 PDT 2015'),
1596
+ Time.parse('Mon Apr 20 19:00:00 PDT 2015'),
1597
+ Time.parse('Mon Apr 27 19:00:00 PDT 2015'),
1598
+ Time.parse('Mon May 4 19:00:00 PDT 2015'),
1599
+ Time.parse('Mon May 11 19:00:00 PDT 2015'),
1600
+ Time.parse('Mon May 18 19:00:00 PDT 2015'),
1601
+ Time.parse('Mon May 25 19:00:00 PDT 2015'),
1602
+ Time.parse('Mon Jun 1 19:00:00 PDT 2015'),
1603
+ Time.parse('Mon Jun 8 19:00:00 PDT 2015'),
1604
+ Time.parse('Mon Jun 15 19:00:00 PDT 2015'),
1605
+ Time.parse('Mon Jun 22 19:00:00 PDT 2015'),
1606
+ Time.parse('Mon Jun 29 19:00:00 PDT 2015'),
1607
+ Time.parse('Mon Jul 6 19:00:00 PDT 2015'),
1608
+ Time.parse('Mon Jul 13 19:00:00 PDT 2015'),
1609
+ Time.parse('Mon Jul 20 19:00:00 PDT 2015'),
1610
+ Time.parse('Mon Jul 27 19:00:00 PDT 2015'),
1611
+ Time.parse('Mon Aug 3 19:00:00 PDT 2015'),
1612
+ Time.parse('Mon Aug 10 19:00:00 PDT 2015'),
1613
+ Time.parse('Mon Aug 17 19:00:00 PDT 2015'),
1614
+ Time.parse('Mon Aug 24 19:00:00 PDT 2015'),
1615
+ Time.parse('Mon Aug 31 19:00:00 PDT 2015'),
1616
+ Time.parse('Mon Sep 7 19:00:00 PDT 2015'),
1617
+ Time.parse('Mon Sep 14 19:00:00 PDT 2015'),
1618
+ Time.parse('Mon Sep 21 19:00:00 PDT 2015'),
1619
+ Time.parse('Mon Sep 28 19:00:00 PDT 2015'),
1620
+ Time.parse('Mon Oct 5 19:00:00 PDT 2015'),
1621
+ Time.parse('Mon Oct 12 19:00:00 PDT 2015'),
1622
+ Time.parse('Mon Oct 19 19:00:00 PDT 2015'),
1623
+ Time.parse('Mon Oct 26 19:00:00 PDT 2015'),
1624
+ Time.parse('Mon Nov 2 19:00:00 PST 2015'),
1625
+ Time.parse('Mon Nov 9 19:00:00 PST 2015'),
1626
+ Time.parse('Mon Nov 16 19:00:00 PST 2015'),
1627
+ Time.parse('Mon Nov 23 19:00:00 PST 2015'),
1628
+ Time.parse('Mon Nov 30 19:00:00 PST 2015'),
1629
+ Time.parse('Mon Dec 7 19:00:00 PST 2015'),
1630
+ Time.parse('Mon Dec 14 19:00:00 PST 2015'),
1631
+ Time.parse('Mon Dec 21 19:00:00 PST 2015'),
1632
+ Time.parse('Mon Dec 28 19:00:00 PST 2015'),
1633
+ Time.parse('Tue Dec 29 19:00:00 PST 2015'),
1634
+ Time.parse('Mon Jan 4 19:00:00 PST 2016'),
1635
+ Time.parse('Mon Jan 11 19:00:00 PST 2016'),
1636
+ Time.parse('Mon Jan 18 19:00:00 PST 2016'),
1637
+ Time.parse('Mon Jan 25 19:00:00 PST 2016'),
1638
+ Time.parse('Mon Feb 1 19:00:00 PST 2016'),
1639
+ Time.parse('Mon Feb 8 19:00:00 PST 2016'),
1640
+ Time.parse('Mon Feb 15 19:00:00 PST 2016'),
1641
+ Time.parse('Mon Feb 22 19:00:00 PST 2016'),
1642
+ Time.parse('Mon Feb 29 19:00:00 PST 2016'),
1643
+ Time.parse('Mon Mar 7 19:00:00 PST 2016'),
1644
+ Time.parse('Mon Mar 14 19:00:00 PDT 2016'),
1645
+ Time.parse('Mon Mar 21 19:00:00 PDT 2016'),
1646
+ Time.parse('Mon Mar 28 19:00:00 PDT 2016'),
1647
+ Time.parse('Mon Apr 4 19:00:00 PDT 2016'),
1648
+ Time.parse('Mon Apr 11 19:00:00 PDT 2016'),
1649
+ Time.parse('Mon Apr 18 19:00:00 PDT 2016'),
1650
+ Time.parse('Mon Apr 25 19:00:00 PDT 2016'),
1651
+ Time.parse('Mon May 2 19:00:00 PDT 2016'),
1652
+ Time.parse('Mon May 9 19:00:00 PDT 2016'),
1653
+ Time.parse('Mon May 16 19:00:00 PDT 2016'),
1654
+ Time.parse('Mon May 23 19:00:00 PDT 2016'),
1655
+ Time.parse('Mon May 30 19:00:00 PDT 2016'),
1656
+ Time.parse('Mon Jun 6 19:00:00 PDT 2016'),
1657
+ Time.parse('Mon Jun 13 19:00:00 PDT 2016'),
1658
+ Time.parse('Mon Jun 20 19:00:00 PDT 2016'),
1659
+ Time.parse('Mon Jun 27 19:00:00 PDT 2016'),
1660
+ Time.parse('Mon Jul 4 19:00:00 PDT 2016'),
1661
+ Time.parse('Mon Jul 11 19:00:00 PDT 2016'),
1662
+ Time.parse('Mon Jul 18 19:00:00 PDT 2016'),
1663
+ Time.parse('Mon Jul 25 19:00:00 PDT 2016'),
1664
+ Time.parse('Mon Aug 1 19:00:00 PDT 2016'),
1665
+ Time.parse('Mon Aug 8 19:00:00 PDT 2016'),
1666
+ Time.parse('Mon Aug 15 19:00:00 PDT 2016'),
1667
+ Time.parse('Mon Aug 22 19:00:00 PDT 2016'),
1668
+ Time.parse('Mon Aug 29 19:00:00 PDT 2016')
1669
+ ])
1670
+ end
1671
+
1672
+ end
1673
+ describe '#between' do
1674
+ it 'returns the correct result with an rrule of FREQ=DAILY;INTERVAL=2' do
1675
+ rrule = 'FREQ=DAILY;INTERVAL=2'
1676
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
1677
+ timezone = 'America/New_York'
1678
+
1679
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1680
+ expect(rrule.between(Time.parse('Tue Sep 2 06:00:00 PDT 1997'), Time.parse('Wed Oct 22 06:00:00 PDT 1997'))).to match_array([
1681
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
1682
+ Time.parse('Thu Sep 4 06:00:00 PDT 1997'),
1683
+ Time.parse('Sat Sep 6 06:00:00 PDT 1997'),
1684
+ Time.parse('Mon Sep 8 06:00:00 PDT 1997'),
1685
+ Time.parse('Wed Sep 10 06:00:00 PDT 1997'),
1686
+ Time.parse('Fri Sep 12 06:00:00 PDT 1997'),
1687
+ Time.parse('Sun Sep 14 06:00:00 PDT 1997'),
1688
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
1689
+ Time.parse('Thu Sep 18 06:00:00 PDT 1997'),
1690
+ Time.parse('Sat Sep 20 06:00:00 PDT 1997'),
1691
+ Time.parse('Mon Sep 22 06:00:00 PDT 1997'),
1692
+ Time.parse('Wed Sep 24 06:00:00 PDT 1997'),
1693
+ Time.parse('Fri Sep 26 06:00:00 PDT 1997'),
1694
+ Time.parse('Sun Sep 28 06:00:00 PDT 1997'),
1695
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
1696
+ Time.parse('Thu Oct 2 06:00:00 PDT 1997'),
1697
+ Time.parse('Sat Oct 4 06:00:00 PDT 1997'),
1698
+ Time.parse('Mon Oct 6 06:00:00 PDT 1997'),
1699
+ Time.parse('Wed Oct 8 06:00:00 PDT 1997'),
1700
+ Time.parse('Fri Oct 10 06:00:00 PDT 1997'),
1701
+ Time.parse('Sun Oct 12 06:00:00 PDT 1997'),
1702
+ Time.parse('Tue Oct 14 06:00:00 PDT 1997'),
1703
+ Time.parse('Thu Oct 16 06:00:00 PDT 1997'),
1704
+ Time.parse('Sat Oct 18 06:00:00 PDT 1997'),
1705
+ Time.parse('Mon Oct 20 06:00:00 PDT 1997'),
1706
+ Time.parse('Wed Oct 22 06:00:00 PDT 1997')
1707
+ ])
1708
+ end
1709
+
1710
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;INTERVAL=2;WKST=SU' do
1711
+ rrule = 'FREQ=WEEKLY;INTERVAL=2;WKST=SU'
1712
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
1713
+ timezone = 'America/New_York'
1714
+
1715
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1716
+ expect(rrule.between(Time.parse('Tue Sep 2 06:00:00 PDT 1997'), Time.parse('Tue Feb 17 06:00:00 PST 1998'))).to match_array([
1717
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
1718
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
1719
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
1720
+ Time.parse('Tue Oct 14 06:00:00 PDT 1997'),
1721
+ Time.parse('Tue Oct 28 06:00:00 PST 1997'),
1722
+ Time.parse('Tue Nov 11 06:00:00 PST 1997'),
1723
+ Time.parse('Tue Nov 25 06:00:00 PST 1997'),
1724
+ Time.parse('Tue Dec 9 06:00:00 PST 1997'),
1725
+ Time.parse('Tue Dec 23 06:00:00 PST 1997'),
1726
+ Time.parse('Tue Jan 6 06:00:00 PST 1998'),
1727
+ Time.parse('Tue Jan 20 06:00:00 PST 1998'),
1728
+ Time.parse('Tue Feb 3 06:00:00 PST 1998'),
1729
+ Time.parse('Tue Feb 17 06:00:00 PST 1998')
1730
+ ])
1731
+ end
1732
+
1733
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYMONTHDAY=-3' do
1734
+ rrule = 'FREQ=MONTHLY;BYMONTHDAY=-3'
1735
+ dtstart = Time.parse('Sun Sep 28 06:00:00 PDT 1997')
1736
+ timezone = 'America/New_York'
1737
+
1738
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1739
+ expect(rrule.between(Time.parse('Sun Sep 28 06:00:00 PDT 1997'), Time.parse('Thu Feb 26 06:00:00 PST 1998'))).to match_array([
1740
+ Time.parse('Sun Sep 28 06:00:00 PDT 1997'),
1741
+ Time.parse('Wed Oct 29 06:00:00 PST 1997'),
1742
+ Time.parse('Fri Nov 28 06:00:00 PST 1997'),
1743
+ Time.parse('Mon Dec 29 06:00:00 PST 1997'),
1744
+ Time.parse('Thu Jan 29 06:00:00 PST 1998'),
1745
+ Time.parse('Thu Feb 26 06:00:00 PST 1998')
1746
+ ])
1747
+ end
1748
+
1749
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;INTERVAL=2;BYDAY=TU' do
1750
+ rrule = 'FREQ=MONTHLY;INTERVAL=2;BYDAY=TU'
1751
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PDT 1997')
1752
+ timezone = 'America/New_York'
1753
+
1754
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1755
+ expect(rrule.between(Time.parse('Tue Sep 2 06:00:00 PDT 1997'), Time.parse('Tue Mar 31 06:00:00 PST 1998'))).to match_array([
1756
+ Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
1757
+ Time.parse('Tue Sep 9 06:00:00 PDT 1997'),
1758
+ Time.parse('Tue Sep 16 06:00:00 PDT 1997'),
1759
+ Time.parse('Tue Sep 23 06:00:00 PDT 1997'),
1760
+ Time.parse('Tue Sep 30 06:00:00 PDT 1997'),
1761
+ Time.parse('Tue Nov 4 06:00:00 PST 1997'),
1762
+ Time.parse('Tue Nov 11 06:00:00 PST 1997'),
1763
+ Time.parse('Tue Nov 18 06:00:00 PST 1997'),
1764
+ Time.parse('Tue Nov 25 06:00:00 PST 1997'),
1765
+ Time.parse('Tue Jan 6 06:00:00 PST 1998'),
1766
+ Time.parse('Tue Jan 13 06:00:00 PST 1998'),
1767
+ Time.parse('Tue Jan 20 06:00:00 PST 1998'),
1768
+ Time.parse('Tue Jan 27 06:00:00 PST 1998'),
1769
+ Time.parse('Tue Mar 3 06:00:00 PST 1998'),
1770
+ Time.parse('Tue Mar 10 06:00:00 PST 1998'),
1771
+ Time.parse('Tue Mar 17 06:00:00 PST 1998'),
1772
+ Time.parse('Tue Mar 24 06:00:00 PST 1998'),
1773
+ Time.parse('Tue Mar 31 06:00:00 PST 1998')
1774
+ ])
1775
+ end
1776
+
1777
+ xit 'returns the correct result with an rrule of FREQ=YEARLY;BYDAY=20MO' do
1778
+ rrule = 'FREQ=YEARLY;BYDAY=20MO'
1779
+ dtstart = Time.parse('Mon May 19 06:00:00 PDT 1997')
1780
+ timezone = 'America/New_York'
1781
+
1782
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1783
+ expect(rrule.between(Time.parse('Mon May 19 06:00:00 PDT 1997'), Time.parse('Mon May 17 06:00:00 PDT 1999'))).to match_array([
1784
+ Time.parse('Mon May 19 06:00:00 PDT 1997'),
1785
+ Time.parse('Mon May 18 06:00:00 PDT 1998'),
1786
+ Time.parse('Mon May 17 06:00:00 PDT 1999')
1787
+ ])
1788
+ end
1789
+
1790
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYWEEKNO=20;BYDAY=MO' do
1791
+ rrule = 'FREQ=YEARLY;BYWEEKNO=20;BYDAY=MO'
1792
+ dtstart = Time.parse('Mon May 12 06:00:00 PDT 1997')
1793
+ timezone = 'America/New_York'
1794
+
1795
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1796
+ expect(rrule.between(Time.parse('Mon May 12 06:00:00 PDT 1997'), Time.parse('Mon May 17 06:00:00 PDT 1999'))).to match_array([
1797
+ Time.parse('Mon May 12 06:00:00 PDT 1997'),
1798
+ Time.parse('Mon May 11 06:00:00 PDT 1998'),
1799
+ Time.parse('Mon May 17 06:00:00 PDT 1999')
1800
+ ])
1801
+ end
1802
+
1803
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=3;BYDAY=TH' do
1804
+ rrule = 'FREQ=YEARLY;BYMONTH=3;BYDAY=TH'
1805
+ dtstart = Time.parse('Thu Mar 13 06:00:00 PST 1997')
1806
+ timezone = 'America/New_York'
1807
+
1808
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1809
+ expect(rrule.between(Time.parse('Thu Mar 13 06:00:00 PST 1997'), Time.parse('Thu Mar 25 06:00:00 PST 1999'))).to match_array([
1810
+ Time.parse('Thu Mar 13 06:00:00 PST 1997'),
1811
+ Time.parse('Thu Mar 20 06:00:00 PST 1997'),
1812
+ Time.parse('Thu Mar 27 06:00:00 PST 1997'),
1813
+ Time.parse('Thu Mar 5 06:00:00 PST 1998'),
1814
+ Time.parse('Thu Mar 12 06:00:00 PST 1998'),
1815
+ Time.parse('Thu Mar 19 06:00:00 PST 1998'),
1816
+ Time.parse('Thu Mar 26 06:00:00 PST 1998'),
1817
+ Time.parse('Thu Mar 4 06:00:00 PST 1999'),
1818
+ Time.parse('Thu Mar 11 06:00:00 PST 1999'),
1819
+ Time.parse('Thu Mar 18 06:00:00 PST 1999'),
1820
+ Time.parse('Thu Mar 25 06:00:00 PST 1999')
1821
+ ])
1822
+ end
1823
+
1824
+ it 'returns the correct result with an rrule of FREQ=YEARLY;BYDAY=TH;BYMONTH=6,7,8' do
1825
+ rrule = 'FREQ=YEARLY;BYDAY=TH;BYMONTH=6,7,8'
1826
+ dtstart = Time.parse('Thu Jun 5 06:00:00 PDT 1997')
1827
+ timezone = 'America/New_York'
1828
+
1829
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1830
+ expect(rrule.between(Time.parse('Thu Jun 5 06:00:00 PDT 1997'), Time.parse('Thu Aug 26 06:00:00 PDT 1999'))).to match_array([
1831
+ Time.parse('Thu Jun 5 06:00:00 PDT 1997'),
1832
+ Time.parse('Thu Jun 12 06:00:00 PDT 1997'),
1833
+ Time.parse('Thu Jun 19 06:00:00 PDT 1997'),
1834
+ Time.parse('Thu Jun 26 06:00:00 PDT 1997'),
1835
+ Time.parse('Thu Jul 3 06:00:00 PDT 1997'),
1836
+ Time.parse('Thu Jul 10 06:00:00 PDT 1997'),
1837
+ Time.parse('Thu Jul 17 06:00:00 PDT 1997'),
1838
+ Time.parse('Thu Jul 24 06:00:00 PDT 1997'),
1839
+ Time.parse('Thu Jul 31 06:00:00 PDT 1997'),
1840
+ Time.parse('Thu Aug 7 06:00:00 PDT 1997'),
1841
+ Time.parse('Thu Aug 14 06:00:00 PDT 1997'),
1842
+ Time.parse('Thu Aug 21 06:00:00 PDT 1997'),
1843
+ Time.parse('Thu Aug 28 06:00:00 PDT 1997'),
1844
+ Time.parse('Thu Jun 4 06:00:00 PDT 1998'),
1845
+ Time.parse('Thu Jun 11 06:00:00 PDT 1998'),
1846
+ Time.parse('Thu Jun 18 06:00:00 PDT 1998'),
1847
+ Time.parse('Thu Jun 25 06:00:00 PDT 1998'),
1848
+ Time.parse('Thu Jul 2 06:00:00 PDT 1998'),
1849
+ Time.parse('Thu Jul 9 06:00:00 PDT 1998'),
1850
+ Time.parse('Thu Jul 16 06:00:00 PDT 1998'),
1851
+ Time.parse('Thu Jul 23 06:00:00 PDT 1998'),
1852
+ Time.parse('Thu Jul 30 06:00:00 PDT 1998'),
1853
+ Time.parse('Thu Aug 6 06:00:00 PDT 1998'),
1854
+ Time.parse('Thu Aug 13 06:00:00 PDT 1998'),
1855
+ Time.parse('Thu Aug 20 06:00:00 PDT 1998'),
1856
+ Time.parse('Thu Aug 27 06:00:00 PDT 1998'),
1857
+ Time.parse('Thu Jun 3 06:00:00 PDT 1999'),
1858
+ Time.parse('Thu Jun 10 06:00:00 PDT 1999'),
1859
+ Time.parse('Thu Jun 17 06:00:00 PDT 1999'),
1860
+ Time.parse('Thu Jun 24 06:00:00 PDT 1999'),
1861
+ Time.parse('Thu Jul 1 06:00:00 PDT 1999'),
1862
+ Time.parse('Thu Jul 8 06:00:00 PDT 1999'),
1863
+ Time.parse('Thu Jul 15 06:00:00 PDT 1999'),
1864
+ Time.parse('Thu Jul 22 06:00:00 PDT 1999'),
1865
+ Time.parse('Thu Jul 29 06:00:00 PDT 1999'),
1866
+ Time.parse('Thu Aug 5 06:00:00 PDT 1999'),
1867
+ Time.parse('Thu Aug 12 06:00:00 PDT 1999'),
1868
+ Time.parse('Thu Aug 19 06:00:00 PDT 1999'),
1869
+ Time.parse('Thu Aug 26 06:00:00 PDT 1999')
1870
+ ])
1871
+ end
1872
+
1873
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYDAY=SA;BYMONTHDAY=7,8,9,10,11,12,13' do
1874
+ rrule = 'FREQ=MONTHLY;BYDAY=SA;BYMONTHDAY=7,8,9,10,11,12,13'
1875
+ dtstart = Time.parse('Sat Sep 13 06:00:00 PDT 1997')
1876
+ timezone = 'America/New_York'
1877
+
1878
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1879
+ expect(rrule.between(Time.parse('Sat Sep 13 06:00:00 PDT 1997'), Time.parse('Sat Jun 13 06:00:00 PDT 1998'))).to match_array([
1880
+ Time.parse('Sat Sep 13 06:00:00 PDT 1997'),
1881
+ Time.parse('Sat Oct 11 06:00:00 PDT 1997'),
1882
+ Time.parse('Sat Nov 8 06:00:00 PST 1997'),
1883
+ Time.parse('Sat Dec 13 06:00:00 PST 1997'),
1884
+ Time.parse('Sat Jan 10 06:00:00 PST 1998'),
1885
+ Time.parse('Sat Feb 7 06:00:00 PST 1998'),
1886
+ Time.parse('Sat Mar 7 06:00:00 PST 1998'),
1887
+ Time.parse('Sat Apr 11 06:00:00 PDT 1998'),
1888
+ Time.parse('Sat May 9 06:00:00 PDT 1998'),
1889
+ Time.parse('Sat Jun 13 06:00:00 PDT 1998')
1890
+ ])
1891
+ end
1892
+
1893
+ it 'returns the correct result with an rrule of FREQ=YEARLY;INTERVAL=4;BYMONTH=11;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8' do
1894
+ rrule = 'FREQ=YEARLY;INTERVAL=4;BYMONTH=11;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8'
1895
+ dtstart = Time.parse('Tue Nov 5 06:00:00 PST 1996')
1896
+ timezone = 'America/New_York'
1897
+
1898
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1899
+ expect(rrule.between(Time.parse('Tue Nov 5 06:00:00 PST 1996'), Time.parse('Tue Nov 2 06:00:00 PST 2004'))).to match_array([
1900
+ Time.parse('Tue Nov 5 06:00:00 PST 1996'),
1901
+ Time.parse('Tue Nov 7 06:00:00 PST 2000'),
1902
+ Time.parse('Tue Nov 2 06:00:00 PST 2004')
1903
+ ])
1904
+ end
1905
+
1906
+ it 'returns the correct result with an rrule of FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2' do
1907
+ rrule = 'FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2'
1908
+ dtstart = Time.parse('Mon Sep 29 06:00:00 PDT 1997')
1909
+ timezone = 'America/New_York'
1910
+
1911
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1912
+ expect(rrule.between(Time.parse('Mon Sep 29 06:00:00 PDT 1997'), Time.parse('Mon Mar 30 06:00:00 PST 1998'))).to match_array([
1913
+ Time.parse('Mon Sep 29 06:00:00 PDT 1997'),
1914
+ Time.parse('Thu Oct 30 06:00:00 PST 1997'),
1915
+ Time.parse('Thu Nov 27 06:00:00 PST 1997'),
1916
+ Time.parse('Tue Dec 30 06:00:00 PST 1997'),
1917
+ Time.parse('Thu Jan 29 06:00:00 PST 1998'),
1918
+ Time.parse('Thu Feb 26 06:00:00 PST 1998'),
1919
+ Time.parse('Mon Mar 30 06:00:00 PST 1998')
1920
+ ])
1921
+ end
1922
+
1923
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=7 when the range extends beyond the end of the recurrence' do
1924
+ rrule ='FREQ=DAILY;COUNT=7'
1925
+ dtstart = Time.parse('Thu Feb 6 16:00:00 PST 2014')
1926
+ timezone = 'America/Los_Angeles'
1927
+
1928
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
1929
+ expect(rrule.between(Time.parse('Sun Feb 9 16:00:00 PST 2014'), Time.parse('Wed Feb 19 16:00:00 PST 2014'))).to match_array([
1930
+ Time.parse('Sun Feb 9 16:00:00 PST 2014'),
1931
+ Time.parse('Mon Feb 10 16:00:00 PST 2014'),
1932
+ Time.parse('Tue Feb 11 16:00:00 PST 2014'),
1933
+ Time.parse('Wed Feb 12 16:00:00 PST 2014')
1934
+ ])
1935
+ end
1936
+
1937
+ it 'returns the correct result with an rrule of FREQ=DAILY;COUNT=10 and an EXDATE' do
1938
+ rrule = 'FREQ=DAILY;COUNT=10'
1939
+ dtstart = Time.parse('Tue Sep 2 06:00:00 PST 1997')
1940
+ timezone = 'America/New_York'
1941
+
1942
+ rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone, exdate: [Time.parse('Fri Sep 5 06:00:00 PST 1997'), Time.parse('Mon Sep 8 06:00:00 PST 1997')])
1943
+ expect(rrule.all).to match_array([
1944
+ Time.parse('Tue Sep 2 06:00:00 PST 1997'),
1945
+ Time.parse('Wed Sep 3 06:00:00 PST 1997'),
1946
+ Time.parse('Thu Sep 4 06:00:00 PST 1997"'),
1947
+ Time.parse('Sat Sep 6 06:00:00 PST 1997'),
1948
+ Time.parse('Sun Sep 7 06:00:00 PST 1997'),
1949
+ Time.parse('Tue Sep 9 06:00:00 PST 1997'),
1950
+ Time.parse('Wed Sep 10 06:00:00 PST 1997'),
1951
+ Time.parse('Thu Sep 11 06:00:00 PST 1997')
1952
+ ])
1953
+ end
1954
+
1955
+ it 'returns the correct result with an rrule of FREQ=WEEKLY;INTERVAL=4;BYDAY=TH' do
1956
+ rrule = 'FREQ=WEEKLY;INTERVAL=4;BYDAY=TH'
1957
+ timezone = 'America/Los_Angeles'
1958
+ dtstart = Time.parse('Thu Jan 28 17:00:00 PST 2016').in_time_zone(timezone)
1959
+
1960
+ rrule = RRule.parse(rrule, dtstart: dtstart, tzid: timezone)
1961
+ expect(rrule.between(Time.parse('Tue May 24 14:34:59 PDT 2016'), Time.parse('Sun Jul 24 14:35:09 PDT 2016'))).to match_array([
1962
+ Time.parse('Thu Jun 16 17:00:00 PDT 2016'),
1963
+ Time.parse('Thu Jul 14 17:00:00 PDT 2016')
1964
+ ])
1965
+ end
1966
+
1967
+ it 'returns the correct result with a date start right on the year border' do
1968
+ rrule = 'FREQ=DAILY'
1969
+ timezone = 'America/Los_Angeles'
1970
+ dtstart = Time.parse('Thu Dec 31 16:00:00 PST 2015')
1971
+
1972
+ rule = RRule.parse(rrule, dtstart: dtstart, tzid: timezone)
1973
+ expect(rule.between(dtstart - 1.month, dtstart + 1.month).first).to eql(dtstart)
1974
+ end
1975
+
1976
+ it 'returns the correct result when BYSETPOS specifies a position that does not exist' do
1977
+ rrule = 'FREQ=MONTHLY;BYDAY=WE;BYSETPOS=5'
1978
+ timezone = 'America/Chicago'
1979
+ dtstart = Time.parse('Wed Jan 30 09:00:00 PST 2013')
1980
+
1981
+ rule = RRule.parse(rrule, dtstart: dtstart, tzid: timezone)
1982
+ start_time = Time.parse('Sun Jul 31 22:00:00 PDT 2016')
1983
+ expected_instance = Time.parse('Wed Aug 31 09:00:00 PDT 2016')
1984
+ end_time = Time.parse('Wed Aug 31 21:59:59 PDT 2016')
1985
+ expect(rule.between(start_time, end_time)).to eql([expected_instance])
1986
+ end
1987
+ end
1988
+ end