@@ -188,64 +188,72 @@ const LogLynxUtils = {
188188 /**
189189 * Format date/time
190190 */
191- formatDateTime : function ( dateStr , options = { } ) {
192- if ( ! dateStr ) return '-' ;
193- try {
194- const date = new Date ( dateStr ) ;
195- const defaultOptions = {
196- year : 'numeric' ,
197- month : 'short' ,
198- day : '2-digit' ,
199- hour : '2-digit' ,
200- minute : '2-digit' ,
201- second : '2-digit' ,
202- hour12 : false ,
203- timeZone : window . LOGLYNX_CONFIG ?. timeZone || 'UTC'
204- } ;
205- return new Intl . DateTimeFormat ( undefined , { ...defaultOptions , ...options } ) . format ( date ) ;
206- } catch ( e ) {
207- return dateStr ;
208- }
209- } ,
210-
211- /**
212- * Format date only
213- */
214- formatDate : function ( dateStr , options = { } ) {
215- if ( ! dateStr ) return '-' ;
216- try {
217- const date = new Date ( dateStr ) ;
218- const defaultOptions = {
219- year : 'numeric' ,
220- month : 'short' ,
221- day : '2-digit' ,
222- timeZone : window . LOGLYNX_CONFIG ?. timeZone || 'UTC'
223- } ;
224- return new Intl . DateTimeFormat ( undefined , { ...defaultOptions , ...options } ) . format ( date ) ;
225- } catch ( e ) {
226- return dateStr ;
227- }
228- } ,
229-
230- /**
231- * Format time only
232- */
233- formatTime : function ( dateStr , options = { } ) {
234- if ( ! dateStr ) return '-' ;
235- try {
236- const date = new Date ( dateStr ) ;
237- const defaultOptions = {
238- hour : '2-digit' ,
239- minute : '2-digit' ,
240- second : '2-digit' ,
241- hour12 : false ,
242- timeZone : window . LOGLYNX_CONFIG ?. timeZone || 'UTC'
243- } ;
244- return new Intl . DateTimeFormat ( undefined , { ...defaultOptions , ...options } ) . format ( date ) ;
245- } catch ( e ) {
246- return dateStr ;
247- }
248- } ,
191+ getTimeZone : function ( ) {
192+ const configuredTz = window . LOGLYNX_CONFIG ?. timeZone ;
193+ if ( ! configuredTz || configuredTz === '' ) {
194+ return 'UTC' ;
195+ }
196+ try {
197+ new Intl . DateTimeFormat ( undefined , { timeZone : configuredTz } ) ;
198+ return configuredTz ;
199+ } catch ( e ) {
200+ console . warn ( 'Invalid timezone configured:' , configuredTz , '- falling back to UTC' ) ;
201+ return 'UTC' ;
202+ }
203+ } ,
204+
205+ formatDateTime : function ( dateStr , options = { } ) {
206+ if ( ! dateStr ) return '-' ;
207+ try {
208+ const date = new Date ( dateStr ) ;
209+ const defaultOptions = {
210+ year : 'numeric' ,
211+ month : 'short' ,
212+ day : '2-digit' ,
213+ hour : '2-digit' ,
214+ minute : '2-digit' ,
215+ second : '2-digit' ,
216+ hour12 : false ,
217+ timeZone : this . getTimeZone ( )
218+ } ;
219+ return new Intl . DateTimeFormat ( undefined , { ...defaultOptions , ...options } ) . format ( date ) ;
220+ } catch ( e ) {
221+ return dateStr ;
222+ }
223+ } ,
224+
225+ formatDate : function ( dateStr , options = { } ) {
226+ if ( ! dateStr ) return '-' ;
227+ try {
228+ const date = new Date ( dateStr ) ;
229+ const defaultOptions = {
230+ year : 'numeric' ,
231+ month : 'short' ,
232+ day : '2-digit' ,
233+ timeZone : this . getTimeZone ( )
234+ } ;
235+ return new Intl . DateTimeFormat ( undefined , { ...defaultOptions , ...options } ) . format ( date ) ;
236+ } catch ( e ) {
237+ return dateStr ;
238+ }
239+ } ,
240+
241+ formatTime : function ( dateStr , options = { } ) {
242+ if ( ! dateStr ) return '-' ;
243+ try {
244+ const date = new Date ( dateStr ) ;
245+ const defaultOptions = {
246+ hour : '2-digit' ,
247+ minute : '2-digit' ,
248+ second : '2-digit' ,
249+ hour12 : false ,
250+ timeZone : this . getTimeZone ( )
251+ } ;
252+ return new Intl . DateTimeFormat ( undefined , { ...defaultOptions , ...options } ) . format ( date ) ;
253+ } catch ( e ) {
254+ return dateStr ;
255+ }
256+ } ,
249257
250258 /**
251259 * Format relative time (e.g., "2 minutes ago")
0 commit comments