feat(clock): timezone, NTP, set-time and clocktower sync in the device Clock tab
Console side of the firmware 3.x TimeKeeper overhaul (project-vesper F-079/F-081/F-083). The Clock tab's "Network & Time" card was read-only and showed fields the firmware no longer reports, and both analog clocks drew the browser's own time. - Time & Timezone card: device local time, zone, mode, UTC offset, DST state (incl. expired manual dates), next change, RTC synced. Read live from the device (system.get_time, clock.get_timezone) - the device is the source of truth for time settings; nothing about them is mirrored to Firestore. - EditTimezoneModal: Automatic (country -> zone from the backend timezone table, or a custom yearly rule built into a POSIX string), Manual DST (std offset, amount, this season's start/end), Fixed, Local only. - SetDeviceTimeModal: this computer's UTC time, or a typed local time. - NTP Sync card + NtpSettingsModal: automatic on/off, nightly time, servers, last result/drift; Sync Now queues clock.sync_ntp and polls clock.get_ntp. - SyncClockModal (was a placeholder): pause, enter what the face shows, clock.set_face + resume. - EditClockSettingsModal: face sync policy force/smart + max wait; mirrored as clockSettings.faceSyncMode / smartMaxWaitMin (added to the backend model, which silently dropped unknown keys - the old gmtOffsetSec/ntpServer mirror never persisted, so those dead drift checks are removed). - Device Time / Clocktower clocks now show the device's wall clock and the real face position (refreshed every 30 s while the clock runs). Live reads are chained after the existing clock.get_config drift check and face polling pauses while a modal or Sync Now is sending, because device replies are matched FIFO without a request id. Stage 5 of project-vesper docs/features/timekeeper-overhaul.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -175,3 +175,35 @@ export function fmtEuro(n) {
|
||||
const f = parseFloat(n) || 0
|
||||
return f.toLocaleString('el-GR', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ' €'
|
||||
}
|
||||
|
||||
// ─── Device wall-clock time ──────────────────────────────────────────────────
|
||||
// A device's local time is in the DEVICE's timezone, not the browser's. These never
|
||||
// convert through the browser timezone: they format wall-clock values as devices report
|
||||
// them (firmware 3.0.0+: "local": "2026-10-28T14:05:00", or a UTC epoch + offset).
|
||||
|
||||
// Formats in UTC so the wall-clock fields come out untouched
|
||||
const WALL_DATETIME = new Intl.DateTimeFormat(LOCALE_LONG, {
|
||||
day: 'numeric', month: 'short', year: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit', hour12: false, timeZone: 'UTC',
|
||||
})
|
||||
|
||||
/** "28 Oct 2026, 14:05" — a device wall-clock string "2026-10-28T14:05:00" */
|
||||
export function fmtWallClock(localIso) {
|
||||
if (!localIso) return '—'
|
||||
const d = safeDate(`${localIso}Z`)
|
||||
return d ? WALL_DATETIME.format(d) : '—'
|
||||
}
|
||||
|
||||
/** "28 Oct 2026, 14:05" — a UTC epoch (seconds) shown in a device's local time */
|
||||
export function fmtDeviceDateTime(utcSeconds, offsetMin) {
|
||||
if (!utcSeconds) return '—'
|
||||
return WALL_DATETIME.format(new Date((utcSeconds + (offsetMin || 0) * 60) * 1000))
|
||||
}
|
||||
|
||||
/** "UTC+02:00" / "UTC-03:30" — minutes east of UTC */
|
||||
export function fmtUtcOffset(minutes) {
|
||||
if (minutes == null) return '—'
|
||||
const sign = minutes >= 0 ? '+' : '-'
|
||||
const abs = Math.abs(minutes)
|
||||
return `UTC${sign}${String(Math.floor(abs / 60)).padStart(2, '0')}:${String(abs % 60).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user