From 036be22fa4859e2bb8669ae2dc8343c16f90411a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 11:55:16 +0000 Subject: [PATCH] Reports: show times in the host's local time zone PHP ignores the host time zone: without date.timezone in php.ini (the installer does not set it) it uses UTC, so session labels, event times, the hour nodes and the live log were shown in UTC while la_mojo names report folders/files in local time. - lib/php/host_timezone.php: sets PHP's default time zone from the host (/etc/localtime as maintained by timedatectl, then /etc/timezone, then TZ); loaded right after settings.php by ajax_asm, assembler, js_asm, soap_asm and ui_asm; added to files.list. - Calendar day key: getHistoryDates returns the host-local noon of each day and getHistoryDay uses it directly. The old "local midnight + current UTC offset" (applied twice) only worked east of UTC and could be off by a day across a DST change. - Video download file name uses the host-local time from getVideoInfo instead of the browser's time zone. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16 --- files.list | 1 + lib/ajax_asm.php | 1 + lib/assembler.php | 1 + lib/controller/getHistoryDates.php | 6 ++-- lib/controller/getHistoryDay.php | 2 +- lib/controller/getVideoInfo.php | 1 + lib/javascript/jsapi_dynamic/mojo_reports.js | 4 ++- lib/js_asm.php | 1 + lib/php/host_timezone.php | 30 ++++++++++++++++++++ lib/soap_asm.php | 1 + lib/ui_asm.php | 1 + 11 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 lib/php/host_timezone.php diff --git a/files.list b/files.list index 6276e8c..b8855f7 100644 --- a/files.list +++ b/files.list @@ -5712,6 +5712,7 @@ ./lib/php/db/VS_Object_class.php ./lib/php/db/SQLite_Class.php ./lib/php/db/report_files.php +./lib/php/host_timezone.php ./lib/php/db/VS_Tree_class.php ./lib/php/db/language_class.php ./lib/php/db/external.php diff --git a/lib/ajax_asm.php b/lib/ajax_asm.php index 2c5e71a..99be3b7 100644 --- a/lib/ajax_asm.php +++ b/lib/ajax_asm.php @@ -1,6 +1,7 @@ 100 ) $CC = 100; $DD[] = '{"t": '.( $TS * 1000 ).',"v":'.$CC.'}'; //echo '[{"t": 1285891200000,"v": 20},{"t": 1285804800000,"v": 100},{"t": 1672249854000,"v": 50},{"t": 1672279854000,"v": 80}]'; diff --git a/lib/controller/getHistoryDay.php b/lib/controller/getHistoryDay.php index 6e179d6..854f55a 100644 --- a/lib/controller/getHistoryDay.php +++ b/lib/controller/getHistoryDay.php @@ -7,7 +7,7 @@ $DT = new DateTime("now", $TZ ); $DIDI = $TZ->getOffset( $DT ); $Data['tz_offset']=$DIDI; - $DTS += $DIDI; + // DTS is the day key from getHistoryDates (host local noon of the day) - no offset correction needed $Y = date("Y", $DTS ); $M = date("m", $DTS ); $D = date("d", $DTS ); diff --git a/lib/controller/getVideoInfo.php b/lib/controller/getVideoInfo.php index 65551b9..996a6c5 100644 --- a/lib/controller/getVideoInfo.php +++ b/lib/controller/getVideoInfo.php @@ -18,6 +18,7 @@ $Pack['videos'] = array(); foreach( $LREC as $Data ){ $Data['id'] = reportEncodeId( $SLOT, $Data['id'] ); + $Data['fname'] = date( "Y_m_d_H-i-s", intval( $Data['ts'] ) ); // download file name in host local time $Pack['videos'][] = $Data; }; echo json_encode( $Pack ); diff --git a/lib/javascript/jsapi_dynamic/mojo_reports.js b/lib/javascript/jsapi_dynamic/mojo_reports.js index 2e11cf2..4c71384 100644 --- a/lib/javascript/jsapi_dynamic/mojo_reports.js +++ b/lib/javascript/jsapi_dynamic/mojo_reports.js @@ -1047,6 +1047,7 @@ function loadEventData( record ){ videoNfo[data.videos[i].media_stream_id][1] = data.videos[i].md5; videoNfo[data.videos[i].media_stream_id][2] = data.videos[i].fps; videoNfo[data.videos[i].media_stream_id][3] = data.videos[i].ext; + videoNfo[data.videos[i].media_stream_id][4] = data.videos[i].fname; // host local time stamp for file name data.videos[i].frame -= 20; if( data.videos[i].frame < 0 ) data.videos[i].frame = 0; @@ -1898,7 +1899,8 @@ function showVideos(){ function downloadCurrentVideo( stid ){ var d = new Date( videoNfo[stid][0] * 1000 ); - var videoFileDownloadTarget = d.getFullYear().toString().padStart(4, '0')+'_'+(d.getMonth()+1).toString().padStart(2, '0')+'_'+d.getDate().toString().padStart(2, '0')+'_'+d.getHours().toString().padStart(2, '0')+'-'+d.getMinutes().toString().padStart(2, '0')+'-'+d.getSeconds().toString().padStart(2, '0'); + // File name in the host's local time (from the server); browser local time only as a fallback + var videoFileDownloadTarget = videoNfo[stid][4] ? videoNfo[stid][4] : d.getFullYear().toString().padStart(4, '0')+'_'+(d.getMonth()+1).toString().padStart(2, '0')+'_'+d.getDate().toString().padStart(2, '0')+'_'+d.getHours().toString().padStart(2, '0')+'-'+d.getMinutes().toString().padStart(2, '0')+'-'+d.getSeconds().toString().padStart(2, '0'); // TS, MD5, FPS, EXT downloadVideoFile( videoNfo[stid][0], videoNfo[stid][1], videoNfo[stid][2], videoFileDownloadTarget, videoNfo[stid][3] ); }; diff --git a/lib/js_asm.php b/lib/js_asm.php index 31ab682..99ec753 100644 --- a/lib/js_asm.php +++ b/lib/js_asm.php @@ -1,6 +1,7 @@ diff --git a/lib/soap_asm.php b/lib/soap_asm.php index bafadc5..da0f192 100644 --- a/lib/soap_asm.php +++ b/lib/soap_asm.php @@ -1,6 +1,7 @@