Skip to content

fix: anchor budget weeks to Monday like the rest of the budget calendar - #9

Closed
Nucletheus wants to merge 1 commit into
mainfrom
fix/monday-anchored-weeks
Closed

Nucletheus wants to merge 1 commit into
mainfrom
fix/monday-anchored-weeks

Conversation

@Nucletheus

Copy link
Copy Markdown
Owner

Summary

The weekly budget layout counted ISO weeks, while every other part of the budget system uses Monday-anchored week numbering (models::budget_week_*: week 1 starts on the Monday on or before January 1). The two calendars diverge whenever January 1 falls on a Friday, Saturday, or Sunday — the first real break is 2027, where ISO reports 52 weeks and Dec 31 falls in ISO week 53. Consequences:

  • the final week of the year (which contains Dec 31) got no weekly budget;
  • per-month weekly amounts were split by the wrong week count.

WeekCountCache now uses the same Monday-anchored calendar, so per-month and per-quarter week counts always sum to total_weeks.

Tests

New tests for 2021 and 2027 (both years start on a Friday):

  • total_weeks == 53 (ISO would report 52);
  • Dec 31 lands in week 53 and week_to_month[53] == 12;
  • December spans 5 Monday-anchored weeks;
  • budget_period_for_date(Weekly, …) agrees with the cache.

Note: I could not run cargo test locally in this sandbox (bundled SQLite needs MSVC cl.exe, unavailable here); cargo fmt --check passes locally and CI runs fmt/clippy/tests.

Also ignores Beira session artifacts (session.json, metrics.jsonl) in .gitignore, and removes the stray untracked wipe.txt scratch file (not part of this commit — it was deleted from the working tree).

The weekly budget layout counted ISO weeks while every other part of the
budget system uses Monday-anchored week numbering (week 1 starts on the
Monday on or before January 1). The two calendars diverge whenever Jan 1
falls on a Friday, Saturday, or Sunday — first real break in 2027, where
ISO reports 52 weeks and Dec 31 lands in week 53, so the final week of
the year got no weekly budget and per-month amounts split by the wrong
week count.

Align the cache with models::budget_week_* and add tests for E:/dev/beira/sessions/dev/TwoCents/2021/2027
(both start on a Friday): 53 weeks, Dec 31 in week 53, December spans
five weeks. Also ignore Beira session artifacts (session.json,
metrics.jsonl).
@Nucletheus Nucletheus closed this Oct 2, 2026
@Nucletheus
Nucletheus deleted the fix/monday-anchored-weeks branch October 2, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant