@@ -2710,44 +2710,62 @@ var layoutUpdateCallback = {
27102710 } ,
27112711} ;
27122712
2713- Behaviour . specify ( ".jenkins-build-timestamp" , 'time-formatter' , 0 , function ( element ) {
2714- const timestampVal = element . getAttribute ( 'data-timestamp' ) ;
2715- const formatPref = element . getAttribute ( 'data-format' ) ;
2716-
2717- if ( ! timestampVal || formatPref === 'auto' ) {
2718- return ;
2719- }
2713+ Behaviour . specify (
2714+ ".jenkins-build-timestamp" ,
2715+ "time-formatter" ,
2716+ 0 ,
2717+ function ( element ) {
2718+ const timestampVal = element . getAttribute ( "data-timestamp" ) ;
2719+ const formatPref = element . getAttribute ( "data-format" ) ;
2720+
2721+ if ( ! timestampVal || formatPref === "auto" ) {
2722+ return ;
2723+ }
27202724
2721- const date = new Date ( parseInt ( timestampVal ) ) ;
2722- if ( isNaN ( date . getTime ( ) ) ) return ;
2725+ const date = new Date ( parseInt ( timestampVal ) ) ;
2726+ if ( isNaN ( date . getTime ( ) ) ) return ;
27232727
2724- if ( formatPref === 'iso8601' ) {
2725- try {
2726- const isoFormatter = new Intl . DateTimeFormat ( 'sv-SE' , {
2727- year : 'numeric' , month : '2-digit' , day : '2-digit' ,
2728- hour : '2-digit' , minute : '2-digit' , hour12 : false
2729- } ) ;
2730- element . innerText = isoFormatter . format ( date ) ;
2731- } catch ( e ) {
2732- const pad = n => String ( n ) . padStart ( 2 , '0' ) ;
2733- element . innerText = date . getFullYear ( ) + '-' + pad ( date . getMonth ( ) + 1 ) + '-' + pad ( date . getDate ( ) ) + ' ' + pad ( date . getHours ( ) ) + ':' + pad ( date . getMinutes ( ) ) ;
2728+ if ( formatPref === "iso8601" ) {
2729+ try {
2730+ const isoFormatter = new Intl . DateTimeFormat ( "sv-SE" , {
2731+ year : "numeric" ,
2732+ month : "2-digit" ,
2733+ day : "2-digit" ,
2734+ hour : "2-digit" ,
2735+ minute : "2-digit" ,
2736+ hour12 : false ,
2737+ } ) ;
2738+ element . innerText = isoFormatter . format ( date ) ;
2739+ } catch ( e ) {
2740+ const pad = ( n ) => String ( n ) . padStart ( 2 , "0" ) ;
2741+ element . innerText =
2742+ date . getFullYear ( ) +
2743+ "-" +
2744+ pad ( date . getMonth ( ) + 1 ) +
2745+ "-" +
2746+ pad ( date . getDate ( ) ) +
2747+ " " +
2748+ pad ( date . getHours ( ) ) +
2749+ ":" +
2750+ pad ( date . getMinutes ( ) ) ;
2751+ }
2752+ return ;
27342753 }
2735- return ;
2736- }
27372754
2738- let options = { } ;
2739- if ( formatPref === ' 24h' ) {
2740- options = { hour : ' numeric' , minute : ' 2-digit' , hour12 : false } ;
2741- } else if ( formatPref === ' 12h' ) {
2742- options = { hour : ' numeric' , minute : ' 2-digit' , hour12 : true } ;
2743- }
2755+ let options = { } ;
2756+ if ( formatPref === " 24h" ) {
2757+ options = { hour : " numeric" , minute : " 2-digit" , hour12 : false } ;
2758+ } else if ( formatPref === " 12h" ) {
2759+ options = { hour : " numeric" , minute : " 2-digit" , hour12 : true } ;
2760+ }
27442761
2745- try {
2746- const formatter = new Intl . DateTimeFormat ( undefined , options ) ;
2747- element . innerText = formatter . format ( date ) ;
2748- } catch ( e ) {
2749- if ( window . console && console . debug ) {
2750- console . debug ( "Failed to format Jenkins timestamp" , e ) ;
2762+ try {
2763+ const formatter = new Intl . DateTimeFormat ( undefined , options ) ;
2764+ element . innerText = formatter . format ( date ) ;
2765+ } catch ( e ) {
2766+ if ( window . console && console . debug ) {
2767+ console . debug ( "Failed to format Jenkins timestamp" , e ) ;
2768+ }
27512769 }
2752- }
2753- } ) ;
2770+ } ,
2771+ ) ;
0 commit comments