Repository navigation
Conversation
A new page's date line and Insert Date/Time showed the stored UTC clock as if it were local time, with no zone, so in Denver at 10:18 a page read 17:18, and near midnight even the date was wrong (AlienTechSoftware#133). Timestamps stay UTC on disk. `model::time` now formats a UTC timestamp on a local offset, which moves the day, month and year with it, and the desktop app sets that offset from the system once at start, while it is the only thread. Without an offset (tests, the command line, the browser build, or if the system cannot say) the clock is UTC, as before. Fixes AlienTechSoftware#133 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Audit finding: the current UTC offset is applied to every timestamp, including dates in a different daylight-saving period. This can change the displayed calendar day. Reproduced against this PR's actual Windows Please resolve the local-zone offset for the timestamp being displayed, with winter/summer and midnight-crossing regression cases, rather than using a single offset captured at startup. Holding this out of the merge batch for the incorrect date display. |
What and why
Fixes #133.
model::time::long_from_iso(anddate_from_iso/clock_from_iso, built on it) took the clock straight from the stored UTC timestamp. A new page's date line, written byformats::templates, and Insert › Time / Date & Time therefore showed UTC with no zone. At 10:18 in Denver a new page said 17:18, and near midnight the date could be wrong too.Stored timestamps stay UTC. Only what is shown changes:
notecraft_model::time: a process-wide local offset (set_local_offset/local_offset, anAtomicI32that defaults to 0).long_from_iso→ newlong_from_iso_at(iso, offset)converts a timestamp ending inZto that clock, moving the day, month and year when needed. A timestamp with no zone is shown as written. It now also rejects an hour over 23 or a minute over 59.apps/notecraft/src/main.rs): on the first line ofmain, while it is the only thread, it readstime::UtcOffset::current_local_offset()and sets the model's offset. It logs the result. On Linux and macOS thetimecrate can only read the local offset safely while the process has a single thread, which is why it happens first.timewas already in the lock (viazip). The workspace now names it withfeatures = ["std", "local-offset"]for the app only, which adds one small crate,num_threads(MIT/Apache-2.0).With no offset set, everything behaves exactly as before: tests,
notecraft-cli, the browser build, or a system that can't report one.Not covered: the offset is read once at start, so a session running across a daylight-saving change keeps the old offset until restart. The UI is English-only, as before. Regional date formats would be a separate change.
How it was checked
time::tests::a_timestamp_is_shown_on_the_users_clock:cargo build -p notecraft, thennotecraft --versionrunscargo test -p notecraft -p notecraft-model -p notecraft-formats -p notecraft-store -p notecraft-engine: passcargo test -p notecraft-ui-egui: all passcargo xtask layers: passcargo fmt --all -- --check,cargo clippy -p notecraft -p notecraft-model --all-targets -- -D warnings: cleanNot checked: on a machine set to a non-UTC zone. The conversion is unit-tested, and reading the offset relies on the
timecrate.🤖 Generated with Claude Code