@@ -43,6 +43,32 @@ const state = {
4343 activeSimulations : new Map ( )
4444} ;
4545
46+ // ==========================================================================
47+ // UTC Time Formatting
48+ // ==========================================================================
49+
50+ /**
51+ * Formats a Date object as UTC time string (HH:MM:SS)
52+ * All times in the dashboard use UTC to match Azure diagnostics data.
53+ * @param {Date } date - The date to format
54+ * @returns {string } UTC time string in HH:MM:SS format
55+ */
56+ function formatUtcTime ( date ) {
57+ if ( ! date || ! ( date instanceof Date ) ) return '' ;
58+ const hours = date . getUTCHours ( ) . toString ( ) . padStart ( 2 , '0' ) ;
59+ const minutes = date . getUTCMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) ;
60+ const seconds = date . getUTCSeconds ( ) . toString ( ) . padStart ( 2 , '0' ) ;
61+ return `${ hours } :${ minutes } :${ seconds } ` ;
62+ }
63+
64+ /**
65+ * Gets the current UTC time as a formatted string
66+ * @returns {string } Current UTC time in HH:MM:SS format
67+ */
68+ function getCurrentUtcTime ( ) {
69+ return formatUtcTime ( new Date ( ) ) ;
70+ }
71+
4672// ==========================================================================
4773// SignalR Connection
4874// ==========================================================================
@@ -136,7 +162,7 @@ function handleMetricsUpdate(snapshot) {
136162 updateCharts ( ) ;
137163
138164 // Update last update time
139- document . getElementById ( 'lastUpdate' ) . textContent = timestamp . toLocaleTimeString ( ) ;
165+ document . getElementById ( 'lastUpdate' ) . textContent = formatUtcTime ( timestamp ) + ' UTC' ;
140166}
141167
142168function updateMetricCard ( type , value , unit , maxForBar ) {
@@ -229,7 +255,7 @@ function initializeCharts() {
229255 maxTicksLimit : 10 ,
230256 callback : ( value , index ) => {
231257 const date = state . metricsHistory . timestamps [ index ] ;
232- return date ? date . toLocaleTimeString ( ) : '' ;
258+ return date ? formatUtcTime ( date ) : '' ;
233259 }
234260 }
235261 } ,
@@ -297,7 +323,7 @@ function initializeCharts() {
297323 maxTicksLimit : 10 ,
298324 callback : ( value , index ) => {
299325 const date = state . metricsHistory . timestamps [ index ] ;
300- return date ? date . toLocaleTimeString ( ) : '' ;
326+ return date ? formatUtcTime ( date ) : '' ;
301327 }
302328 }
303329 } ,
@@ -357,7 +383,7 @@ function initializeCharts() {
357383 maxTicksLimit : 10 ,
358384 callback : ( value , index ) => {
359385 const date = state . latencyHistory . timestamps [ index ] ;
360- return date ? date . toLocaleTimeString ( ) : '' ;
386+ return date ? formatUtcTime ( date ) : '' ;
361387 }
362388 }
363389 } ,
@@ -400,7 +426,7 @@ function initializeCharts() {
400426
401427function updateCharts ( ) {
402428 const history = state . metricsHistory ;
403- const labels = history . timestamps . map ( t => t . toLocaleTimeString ( ) ) ;
429+ const labels = history . timestamps . map ( t => formatUtcTime ( t ) ) ;
404430
405431 // Update resource chart
406432 state . charts . resource . data . labels = labels ;
@@ -551,7 +577,7 @@ function updateLatencyChart() {
551577 return '#107c10' ;
552578 } ) ;
553579
554- state . charts . latency . data . labels = history . timestamps . map ( t => t . toLocaleTimeString ( ) ) ;
580+ state . charts . latency . data . labels = history . timestamps . map ( t => formatUtcTime ( t ) ) ;
555581 state . charts . latency . data . datasets [ 0 ] . data = history . values ;
556582 state . charts . latency . data . datasets [ 0 ] . backgroundColor = gradient ;
557583 state . charts . latency . data . datasets [ 0 ] . borderColor = pointColors ;
@@ -847,11 +873,11 @@ function updateActiveSimulationsUI() {
847873
848874function logEvent ( level , message ) {
849875 const log = document . getElementById ( 'eventLog' ) ;
850- const time = new Date ( ) . toLocaleTimeString ( ) ;
876+ const time = getCurrentUtcTime ( ) ;
851877
852878 const entry = document . createElement ( 'div' ) ;
853879 entry . className = `log-entry ${ level } ` ;
854- entry . innerHTML = `<span class="log-time">${ time } </span>${ message } ` ;
880+ entry . innerHTML = `<span class="log-time">${ time } UTC </span>${ message } ` ;
855881
856882 log . insertBefore ( entry , log . firstChild ) ;
857883
0 commit comments