File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9595 }
9696
9797 function formatTimestamp(ts : string ) {
98- return new Date (ts ).toLocaleString ();
98+ const timeZone = Intl .DateTimeFormat ().resolvedOptions ().timeZone ;
99+ return new Date (ts ).toLocaleString (' en-US' , { timeZone });
99100 }
100101
101102 const selectedData = $derived .by (() => {
Original file line number Diff line number Diff line change 237237 function formatTimestamp(ts : string ): string {
238238 try {
239239 const date = new Date (ts );
240- return date .toLocaleString ();
240+ const timeZone = Intl .DateTimeFormat ().resolvedOptions ().timeZone ;
241+ return date .toLocaleString (' en-US' , { timeZone });
241242 } catch {
242243 return ts ;
243244 }
Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ export function formatTimestamp(
4242 hour12 : false
4343 } ;
4444
45- const local = date . toLocaleString ( undefined , localParams ) ;
45+ const timeZone : string | undefined =
46+ typeof Intl !== 'undefined' ? Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone : undefined ;
47+ const local = date . toLocaleString ( 'en-US' , { ...localParams , timeZone } ) ;
4648 const utc = date
4749 . toISOString ( )
4850 . replace ( 'T' , ' ' )
@@ -53,10 +55,11 @@ export function formatTimestamp(
5355 const hour = date . getHours ( ) ;
5456 if ( hour < 4 ) {
5557 const prevDate = new Date ( num - 24 * 60 * 60 * 1000 ) ;
56- const prevDateStr = prevDate . toLocaleDateString ( undefined , {
58+ const prevDateStr = prevDate . toLocaleDateString ( 'en-US' , {
5759 year : 'numeric' ,
5860 month : 'short' ,
59- day : 'numeric'
61+ day : 'numeric' ,
62+ timeZone
6063 } ) ;
6164 const serviceHour = hour + 24 ;
6265 const minutes = date . getMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) ;
You can’t perform that action at this time.
0 commit comments