fix: anchor budget weeks to Monday like the rest of the budget calendar - #9
Closed
Nucletheus wants to merge 1 commit into
Closed
Nucletheus wants to merge 1 commit into
Nucletheus wants to merge 1 commit into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:WeekCountCachenow uses the same Monday-anchored calendar, so per-month and per-quarter week counts always sum tototal_weeks.Tests
New tests for 2021 and 2027 (both years start on a Friday):
total_weeks == 53(ISO would report 52);week_to_month[53] == 12;budget_period_for_date(Weekly, …)agrees with the cache.Note: I could not run
cargo testlocally in this sandbox (bundled SQLite needs MSVCcl.exe, unavailable here);cargo fmt --checkpasses locally and CI runs fmt/clippy/tests.Also ignores Beira session artifacts (
session.json,metrics.jsonl) in.gitignore, and removes the stray untrackedwipe.txtscratch file (not part of this commit — it was deleted from the working tree).