11import { settings } from './variables/settings.js' ;
22import { compareRunIds } from './variables/graphs.js' ;
33import { runs , suites , tests , keywords , unified_dashboard_title } from './variables/data.js' ;
4- import { show_loading_overlay , hide_loading_overlay } from './common.js' ;
4+ import { show_loading_overlay , hide_loading_overlay , strip_tz_suffix } from './common.js' ;
55import { set_local_storage_item } from './localstorage.js' ;
66import {
77 filteredAmount ,
@@ -13,6 +13,16 @@ import {
1313 selectedTagSetting
1414} from './variables/globals.js' ;
1515
16+ // Sort an array of run objects by wall-clock run_start (timezone offset stripped),
17+ // ensuring correct chronological order when timestamps span mixed timezone offsets.
18+ function sort_wall_clock ( data ) {
19+ return [ ...data ] . sort ( ( a , b ) => {
20+ const ak = strip_tz_suffix ( a . run_start ) ;
21+ const bk = strip_tz_suffix ( b . run_start ) ;
22+ return ak < bk ? - 1 : ak > bk ? 1 : 0 ;
23+ } ) ;
24+ }
25+
1626// function updates the data in the graphs whenever filters are updated
1727function setup_filtered_data_and_filters ( ) {
1828 filteredRuns = remove_milliseconds ( runs )
@@ -40,6 +50,13 @@ function setup_filtered_data_and_filters() {
4050 filteredSuites = filter_data ( filteredSuites ) ;
4151 filteredTests = filter_data ( filteredTests ) ;
4252 filteredKeywords = filter_data ( filteredKeywords ) ;
53+ // re-sort all filtered data by wall-clock run_start so mixed-timezone datasets
54+ // appear in the correct chronological order on graphs (timestamps may have been
55+ // converted or had their offsets stripped above, so re-sort here is the source of truth)
56+ filteredRuns = sort_wall_clock ( filteredRuns ) ;
57+ filteredSuites = sort_wall_clock ( filteredSuites ) ;
58+ filteredTests = sort_wall_clock ( filteredTests ) ;
59+ filteredKeywords = sort_wall_clock ( filteredKeywords ) ;
4360 // set titles with amount of filtered items
4461 const runAmount = Object . keys ( filteredRuns ) . length
4562 const message = `<h6>showing ${ runAmount } of ${ filteredAmount } runs</h6>`
@@ -220,7 +237,13 @@ function filter_dates(runs) {
220237 return runs ; // Return all runs if invalid range
221238 }
222239 return runs . filter ( run => {
223- const runStart = new Date ( run . run_start . replace ( " " , "T" ) ) ;
240+ // When not converting timezones, strip any timezone offset so the run_start is treated
241+ // as a plain wall-clock time matching the date picker values (which are also wall-clock).
242+ let rs = run . run_start . replace ( " " , "T" ) ;
243+ if ( ! settings . show . convertTimezone ) {
244+ rs = strip_tz_suffix ( rs ) ;
245+ }
246+ const runStart = new Date ( rs ) ;
224247 return runStart >= fromDateTime && runStart <= toDateTime ;
225248 } ) ;
226249}
0 commit comments