Repository navigation
Use the local day of the last Habitica cron for the calendars - #184613
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused correction and regression expectations are consistent, with no blocking issues identified; tests were not run.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes Habitica calendars using the UTC date instead of the local date of the last cron.
Changes:
- Converts the last cron to local time before deriving the day, preserving the fallback when absent.
- Adds a timezone regression test and updates calendar snapshots.
| File | Description |
|---|---|
| tests/components/habitica/test_calendar.py | Tests the local-day boundary case. |
| tests/components/habitica/snapshots/test_calendar.ambr | Updates expected daily and reminder events. |
| homeassistant/components/habitica/calendar.py | Corrects the shared local-day calculation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Generated by quality-scale-reviewer · copilot · auto · 125.9 AIC · ⌖ 4.79 AIC · ⊞ 8.1K
epenet
left a comment
There was a problem hiding this comment.
Coverage could be improved, but it's not blocking.
It could be covered by parametrizing the new test, e.g. setting habitica.get_user.return_value.data.lastCron = None and asserting the dailies start today.

Breaking change
Proposed change
The Habitica calendars derive "today" from the user's last cron, but passed the UTC
lastCrontimestamp straight tostart_of_local_day, which takes the date part as is. When the cron ran shortly after local midnight in a timezone ahead of UTC (for example 00:03 in Europe/Berlin, which is still the previous day in UTC), the calendars treated yesterday as today: yesterday's open dailies showed up as current and today's completed dailies were still listed.The last cron is now converted to local time before taking the start of the day, like the to-do platform already does. The existing test fixture happens to have exactly this case, so the calendar snapshots are updated to the correct day.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: