Skip to content

Commit

Permalink
correct date adjustment for recurring events in planner
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenkov committed Jan 6, 2025
1 parent 4acb215 commit 1151a2d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ func query(
debug("event = %q name = %q value = %q\n", event, rrule.Name, rrule.Value)
if rrule.Value == "FREQ=WEEKLY" {
//
// adjust the start time so that it occurs this week
// fast-forward the start time so that it occurs during this week
//
year, week := today.ISOWeek()
y, w := event.Start.ISOWeek()
newStart := event.Start.AddDate(year-y, 0, 7*(week-w))
event.Start = newStart
today_year, today_week := today.ISOWeek()
for {
event_year, event_week := event.Start.ISOWeek()
if today_year == event_year && today_week == event_week {
break
}
event.Start = event.Start.AddDate(0, 0, 7)
}
} else {
debug("summary = %q date expansion for rrule %q not implemented\n", summary, rrule.Value)
}
Expand Down

0 comments on commit 1151a2d

Please sign in to comment.