File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -757,16 +757,25 @@ function Date:apply_repeater()
757
757
if not repeater then
758
758
return self
759
759
end
760
+
761
+ -- Repeater relative to completion time
760
762
if repeater :match (' ^%.%+%d+' ) then
761
- return date :set_todays_date ():adjust (repeater :sub (2 ))
763
+ -- Strip the '.' from the repeater
764
+ local offset = repeater :sub (2 )
765
+ return date :set_todays_date ():adjust (offset )
762
766
end
767
+
768
+ -- Repeater relative to deadline/scheduled date
763
769
if repeater :match (' ^%+%+%d' ) then
764
- while date .timestamp < current_time .timestamp do
765
- date = date :adjust (repeater :sub (2 ))
766
- end
770
+ -- Strip the '+' from the repeater
771
+ local offset = repeater :sub (2 )
772
+ repeat
773
+ date = date :adjust (offset )
774
+ until date .timestamp > current_time .timestamp
767
775
return date
768
776
end
769
777
778
+ -- Simple repeat; apply repeater once to deadline/scheduled date
770
779
return date :adjust (repeater )
771
780
end
772
781
Original file line number Diff line number Diff line change @@ -571,6 +571,13 @@ describe('Date object', function()
571
571
assert .are .same (inTwoWeeks :to_string (), sunday :apply_repeater_until (inTwoWeeks ):to_string ())
572
572
end )
573
573
574
+ it (' should apply repeater to future dates' , function ()
575
+ local tomorrow = Date .now ({ adjustments = { ' ++1d' } }):add ({ day = 1 })
576
+ local day_after_tomorrow = tomorrow :add ({ day = 1 })
577
+ local updated_date = tomorrow :apply_repeater ()
578
+ assert .are .same (updated_date :to_string (), day_after_tomorrow :to_string ())
579
+ end )
580
+
574
581
it (' should cache check for today' , function ()
575
582
local today = Date .today ()
576
583
assert .is .Nil (today .is_today_date )
You can’t perform that action at this time.
0 commit comments