Skip to content

Add an optional time to add_food_entry and add_note - #91

Merged
rwestergren merged 2 commits into
rwestergren:mainfrom
knauerhase:time-param
Nov 22, 2026
Merged

rwestergren merged 2 commits into
rwestergren:mainfrom
knauerhase:time-param

Conversation

@knauerhase

Copy link
Copy Markdown
Contributor

Entries and notes are always stamped with the current time. Logging a meal late therefore puts it at the wrong time of day and, with diary_group="auto", in the wrong meal slot. This adds an optional time argument.

What it does

  • add_food_entry and add_note take time (24-hour HH:MM or HH:MM:SS, in the account timezone). It sets the stamped time and drives the "auto" slot through the existing _meal_group_for_hour. A bad value returns an error and writes nothing.
  • add_serving and add_note take a matching at argument on the client.
  • Notes now send time and offset in the /photoupload form, as the app's own notes do. I checked this against the live API: both fields are stored and come back on read.
  • The offset is the UTC offset in force on the note's own date and time in the account zone. A backfill across a DST change gets the right value, because a plain "offset now" would be off by an hour.
  • update_note sends the stored time and offset back, so an edit keeps them.

Behavior changes

  • Food entries behave exactly as before when time is omitted.
  • Notes now carry a time and offset even when time is omitted (the current time).

Not included: nothing in this PR changes meal-group handling. That's tracked in #90. time only feeds the existing hour-to-group function, so it works with whatever #90 decides.

Tests: 14 new tests, covering time passing through the tools, invalid times, at driving the auto group, the offset across DST, and update_note keeping time and offset. Ruff, ruff format --check and the full suite pass.

🤖 Generated with Claude Code

knauerhase and others added 2 commits November 21, 2026 22:35
Entries and notes were always stamped with the current time, so logging a
meal late put it at the wrong time of day and, with diary_group "auto", in
the wrong meal slot. add_food_entry and add_note now take time (HH:MM or
HH:MM:SS, account timezone). It sets the stamped time and picks the auto
group; omitted, behaviour is unchanged for food entries.

Notes now carry time and offset in the /photoupload form, as the app's own
notes do (checked against the live API). The offset is the UTC offset in
force on the note's own date and time in the account zone, so a note
backfilled across a DST change is right. update_note sends the stored time
and offset back so an edit keeps them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rwestergren
rwestergren merged commit 4f1946d into rwestergren:main Nov 22, 2026
1 check passed
@knauerhase

Copy link
Copy Markdown
Contributor Author

Thanks for merging this so quickly, and for #92. I checked it against my own account (DG01 is Breakfast and Uncategorized is group 4): "breakfast" resolves to group 0, "Uncategorized" to group 4, and "auto" picks the right slot by time of day. I also wrote one test note to each group and they read back in the right group, then removed them. Everything worked as expected.

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.

2 participants