public
Description: Tracks is a GTD(TM) web application, built with Ruby on Rails
Homepage: http://www.rousette.org.uk/projects/
Clone URL: git://github.com/bsag/tracks.git
Click here to lend your support to: tracks and make a donation at www.pledgie.com !
fix case where future start_from was ignored for yearly recurrence patterns
lrbalt (author)
Tue Aug 19 12:25:25 -0700 2008
commit  f4378ffde1b2364bbcbf999191a76f580fa02904
tree    77fd8941fabe8f4ac53ac5b6309244f5ca5d1515
parent  666f524b16c847cf8b3d241636e57087097306dc
...
508
509
510
511
 
 
 
 
 
 
 
512
513
514
...
508
509
510
 
511
512
513
514
515
516
517
518
519
520
0
@@ -508,7 +508,13 @@ class RecurringTodo < ActiveRecord::Base
0
     if previous.nil?
0
       start = self.start_from.nil? ? Time.now.utc : self.start_from
0
     else
0
-      start = previous
0
+      if self.start_from.nil?
0
+        start = previous
0
+      else
0
+        # check if the start_from date is later than previous. If so, use
0
+        # start_from as start to search for next date
0
+        start = self.start_from > previous ? self.start_from : previous
0
+      end
0
     end
0
 
0
     day = self.every_other1
...
203
204
205
 
 
 
 
 
 
 
206
207
208
...
203
204
205
206
207
208
209
210
211
212
213
214
215
0
@@ -203,6 +203,13 @@ class RecurringTodoTest < Test::Rails::TestCase
0
     due_date1 = @yearly.get_due_date(nil) 
0
     due_date2 = @yearly.get_due_date(Time.now.utc + 1.day)
0
     assert_equal due_date1, due_date2
0
+  end
0
+
0
+  def test_start_from_in_future
0
+    # start from after june 8th 2008
0
+    @yearly.start_from = Time.utc(2008,6,12)
0
+    assert_equal Time.utc(2009,6,8), @yearly.get_due_date(nil) # jun 8th next year
0
+    assert_equal Time.utc(2009,6,8), @yearly.get_due_date(Time.utc(2008,6,1)) # also next year
0
     
0
     this_year = Time.now.utc.year
0
     @yearly.start_from = Time.utc(this_year+1,6,12)

Comments