mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
fix(sim): add sim_test_set_timezone_hours() -- clock was showing UTC
NodePrefs::tz_offset_hours defaults to 0 (UTC) -- correct for real hardware, which has no other way to know the visitor's timezone besides Settings > System > Timezone. SimRTCClock (see718dbdbe) is already correct live UTC (time(NULL)), but without a timezone applied, a demo instance's Clock screen displayed correct-but-UTC time, which just reads as "wrong" to a visitor who never opened Settings -- e.g. 20:40 shown while it was really 22:40 CEST. This is the other half of the site's "would be nice if the time was synced with the computer" ask;718dbdbeonly fixed the stale-IDBFS-restore half. sim_test_set_timezone_hours(int) is a new sim-only hook, same shape as sim_test_show_all_home_pages(): meshcore-solo-site calls it once after boot with the browser's own timezone offset. Whole hours only (tz_offset_hours is an int8_t) -- same limit a real device's own Settings field has. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018iubftDmKNWmkNnhJRz8UH
This commit is contained in:
@@ -446,6 +446,26 @@ extern "C" EMSCRIPTEN_KEEPALIVE int sim_test_show_all_home_pages() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// tz_offset_hours (NodePrefs.h) defaults to 0 (UTC) -- real hardware has
|
||||
// no other way to know the visitor's timezone, so a real user sets it
|
||||
// manually in Settings > System > Timezone. RTCClock itself (SimRTCClock.h)
|
||||
// is already correct live UTC (time(NULL)), so a demo instance's Clock
|
||||
// screen otherwise displays correct-but-UTC time, which reads as "wrong"
|
||||
// to a visitor who never opened Settings -- exactly the site's own
|
||||
// "would be nice if the time was synced with the computer" ask. Called
|
||||
// once after boot with the browser's own timezone offset (whole hours
|
||||
// only -- tz_offset_hours is an int8_t, same real-hardware constraint a
|
||||
// half-hour-offset timezone would hit too).
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE int sim_test_set_timezone_hours(int hours) {
|
||||
if (!g_sim_ready) return 0;
|
||||
NodePrefs* prefs = the_mesh.getNodePrefs();
|
||||
if (!prefs) return 0;
|
||||
if (hours < -12) hours = -12;
|
||||
if (hours > 14) hours = 14;
|
||||
prefs->tz_offset_hours = (int8_t)hours;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
// Jumps the on-device UI straight to the DM thread with the first known
|
||||
// ADV_TYPE_CHAT contact (UITask::openContactDM() -- the exact same real
|
||||
|
||||
Reference in New Issue
Block a user