1764623999 is 2025-12-01 21:19:59 UTC, not 19:59:59. Pointed out by
Copilot review on PR #4871.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SystemTimePointToMysqlString appended ".%06d" microseconds to the string it
hands MySQL for the Events.StartDateTime datetime column. That column has no
fractional precision, and MySQL 8 ROUNDS a fractional value when storing it, so
a start_time of 23:59:59.5xx-.999999 local was promoted to 00:00:00 of the next
day. Event::SetPath() derives the on-disk day folder from to_time_t(start_time),
which truncates, so it landed on the previous day.
For continuous recording the event start is backdated to the preceding keyframe,
which for a section forced closed at local midnight falls just before midnight.
On MySQL 8 the DB row then recorded the next day while the files were written
under the previous day's folder, producing a permanent zmaudit path mismatch and
orphaned files when the event aged out (the purge path is built from
StartDateTime).
Format the value to whole seconds only so it matches to_time_t() used by
SetPath(), keeping the DB row and the disk folder on the same second regardless
of whether the DB engine rounds or truncates.
Add tests/zm_time.cpp covering the floor-not-round behaviour and consistency
with the to_time_t-derived path second.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>