Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Gemfile.lock
*.sublime-workspace
.ruby-version
gemfiles/*.lock
.idea
8 changes: 4 additions & 4 deletions lib/rrule/rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ def parse_options(rule)
end
end

unless options[:byweekno] || options[:byyearday] || options[:bymonthday] || options[:byweekday]
unless options[:byweekno] || options[:byyearday] || options[:byweekday]
case options[:freq]
when 'YEARLY'
options[:bymonth] = [dtstart.month] unless options[:bymonth]
options[:bymonthday] = [dtstart.day]
options[:bymonth] = [dtstart.month] unless options[:bymonth] || (options[:bymonthday] && options[:count])
options[:bymonthday] = [dtstart.day] unless options[:bymonthday]
when 'MONTHLY'
options[:bymonthday] = [dtstart.day]
options[:bymonthday] = [dtstart.day] unless options[:bymonthday]
when 'WEEKLY'
options[:simple_weekly] = true
options[:byweekday] = [Weekday.new(dtstart.wday)]
Expand Down
14 changes: 14 additions & 0 deletions spec/rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,20 @@
])
end

it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTHDAY=25' do
rrule = 'FREQ=YEARLY;BYMONTHDAY=25'
dtstart = Time.parse('Mon Apr 1 19:00:00 PDT 2024')
timezone = 'America/Los_Angeles'

rrule = RRule::Rule.new(rrule, dtstart: dtstart, tzid: timezone)
expect(rrule.between(Time.parse('Thu Mar 13 06:00:00 PST 2024'), Time.parse('Thu Mar 25 06:00:00 PST 2028'))).to match_array([
Time.parse('Mon Apr 25 19:00:00 PDT 2024'),
Time.parse('Mon Apr 25 19:00:00 PDT 2025'),
Time.parse('Mon Apr 25 19:00:00 PDT 2026'),
Time.parse('Mon Apr 25 19:00:00 PDT 2027'),
])
end

it 'returns the correct result with an rrule of FREQ=YEARLY;BYMONTH=3;BYDAY=TH' do
rrule = 'FREQ=YEARLY;BYMONTH=3;BYDAY=TH'
dtstart = Time.parse('Thu Mar 13 06:00:00 PST 1997')
Expand Down