diff --git a/app/models/recurring_todo.rb b/app/models/recurring_todo.rb index 86b24dae..0b103b03 100644 --- a/app/models/recurring_todo.rb +++ b/app/models/recurring_todo.rb @@ -517,17 +517,18 @@ class RecurringTodo < ActiveRecord::Base end def get_yearly_date(previous) - start = determine_start(previous) day = self.every_other1 month = self.every_other2 case self.recurrence_selector when 0 # specific day of a specific month - # if there is no next month n in this year, search in next year - if start.month >= month - start = Time.zone.local(start.year+1, month, 1) if start.day >= day - start = Time.zone.local(start.year, month, 1) if start.day <= day + if start.month > month || (start.month == month && start.day > day) + # if there is no next month n and day m in this year, search in next year + start = Time.zone.local(start.year+1, month, 1) + else + # if there is a next month n, stay in this year + start = Time.zone.local(start.year, month, 1) end return Time.zone.local(start.year, month, day) diff --git a/test/unit/recurring_todo_test.rb b/test/unit/recurring_todo_test.rb index bd256eba..82ba1cb5 100644 --- a/test/unit/recurring_todo_test.rb +++ b/test/unit/recurring_todo_test.rb @@ -174,6 +174,9 @@ class RecurringTodoTest < Test::Rails::TestCase # same month, day after due_date = @yearly.get_due_date(@monday) # june 9th assert_equal Time.zone.local(2009,6,8), due_date # june 8th next year + # very overdue + due_date = @yearly.get_due_date(@monday+5.months-2.days) # november 7 + assert_equal Time.zone.local(2009,6,8), due_date # june 8th next year @yearly.recurrence_selector = 1 @yearly.every_other3 = 2 # second