tududi/backend/modules/tasks
Chris 077addadde
Fix recurring task initial due date calculation to match recurrence pattern (#965)
* Fix recurring task initial due date calculation to match recurrence pattern

Resolves #963

When creating a recurring task without an explicit due date, the system
was incorrectly setting it to "today" regardless of the recurrence pattern.
This caused issues where:
- Monthly tasks set to recur on a specific day (e.g., 28th) would show the
  wrong due date (today/yesterday instead of the 28th)
- Tasks wouldn't appear correctly in the Upcoming view
- The base due_date didn't match the recurrence_month_day setting

Changes:
- Add calculateInitialDueDate() helper to compute correct first occurrence
- For monthly recurrence with specific day: calculate next occurrence of that day
- For weekly recurrence with specific weekday: calculate next occurrence of that weekday
- For other types (daily, etc.): maintain current behavior (use today)
- Apply same logic to both task creation and updates

Tests:
- Add comprehensive test suite (9 new tests) covering:
  - Monthly recurrence with future day in current month
  - Monthly recurrence with past day (should use next month)
  - Weekly recurrence with specific weekday
  - Daily recurrence (should still default to today)
  - Edge cases (31st of month, explicitly provided dates)
  - Task updates adding recurrence

All 54 recurring task tests pass.

* Fix UTC timezone bug in recurring task expansion and add comprehensive tests

- Fix expandRecurringTasks() to use setUTCHours instead of setHours
- Add 42 unit tests for recurringTaskService UTC consistency
- Add 24 DST transition tests (spring forward/fall back)
- Verify no occurrence skips or duplicates during DST
- Test month-end handling, leap years, and timezone boundaries
2026-03-23 18:24:54 +02:00
..
core Fix recurring task initial due date calculation to match recurrence pattern (#965) 2026-03-23 18:24:54 +02:00
middleware Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
operations Fix bi-weekly+ recurring tasks reverting to weekly (#844) (#890) 2026-03-02 23:36:47 +02:00
queries Fix subtask ordering to prevent random reordering (#930) 2026-03-10 00:17:26 +02:00
utils Fix defer date validation for recurring task instances (#910) 2026-03-05 08:20:30 +02:00
attachments.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
deferredTaskService.js Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
dueTaskService.js Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
events.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
index.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
recurringTaskService.js Fix bi-weekly+ recurring tasks reverting to weekly (#844) (#890) 2026-03-02 23:36:47 +02:00
repository.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
routes.js Fix recurring task initial due date calculation to match recurrence pattern (#965) 2026-03-23 18:24:54 +02:00
taskEventService.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
taskScheduler.js Fix issue with wrong path 2026-01-18 09:47:12 +02:00
taskSummaryService.js Fix Telegram task display bug by escaping backslashes (#860) 2026-02-24 14:19:45 +02:00