@@ -3537,50 +3537,60 @@ function sandBox(script, name, verbose, debug, context) {
35373537 const neg = diff < 0 ;
35383538 diff = Math . abs ( diff ) ;
35393539
3540- if ( / D D | T T | Д Д | D | T | Д / . test ( text ) ) {
3540+ if ( / (?< ! \\ ) ( D | T | Д ) / . test ( text ) ) {
35413541 const days = Math . floor ( diff / day ) ;
35423542
3543- text = text . replace ( / D D | T T | Д Д / , days < 10 ? `0${ days } ` : days ) ;
3544- text = text . replace ( / D | T | Д / , days ) ;
3543+ text = text
3544+ . replace ( / (?< ! \\ ) ( D D | T T | Д Д ) / g, days < 10 ? `0${ days } ` : days )
3545+ . replace ( / (?< ! \\ ) ( D | T | Д ) / g, days ) ;
35453546
35463547 sandbox . verbose && sandbox . log ( `formatTimeDiff(format=${ format } , text=${ text } , days=${ days } )` , 'debug' ) ;
35473548
35483549 diff -= days * day ;
35493550 }
35503551
3551- if ( / h h | S S | ч ч | h | S | ч / . test ( text ) ) {
3552+ if ( / (?< ! \\ ) ( h | S | ч ) / . test ( text ) ) {
35523553 const hours = Math . floor ( diff / hour ) ;
35533554
3554- text = text . replace ( / h h | S S | ч ч / , hours < 10 ? `0${ hours } ` : hours ) ;
3555- text = text . replace ( / h | S | ч / , hours ) ;
3555+ text = text
3556+ . replace ( / (?< ! \\ ) ( h h | S S | ч ч ) / g, hours < 10 ? `0${ hours } ` : hours )
3557+ . replace ( / (?< ! \\ ) ( h | S | ч ) / g, hours ) ;
35563558
35573559 sandbox . verbose && sandbox . log ( `formatTimeDiff(format=${ format } , text=${ text } , hours=${ hours } )` , 'debug' ) ;
35583560
35593561 diff -= hours * hour ;
35603562 }
35613563
3562- if ( / m m | м м | m | м / . test ( text ) ) {
3564+ if ( / (?< ! \\ ) ( m | м ) / . test ( text ) ) {
35633565 const minutes = Math . floor ( diff / minute ) ;
35643566
3565- text = text . replace ( / m m | м м / , minutes < 10 ? `0${ minutes } ` : minutes ) ;
3566- text = text . replace ( / m | м / , minutes ) ;
3567+ text = text
3568+ . replace ( / (?< ! \\ ) ( m m | м м ) / g, minutes < 10 ? `0${ minutes } ` : minutes )
3569+ . replace ( / (?< ! \\ ) ( m | м ) / g, minutes ) ;
35673570
35683571 sandbox . verbose && sandbox . log ( `formatTimeDiff(format=${ format } , text=${ text } , minutes=${ minutes } )` , 'debug' ) ;
35693572
35703573 diff -= minutes * minute ;
35713574 }
35723575
3573- if ( / s s | с с | м м | s | с / . test ( text ) ) {
3576+ if ( / (?< ! \\ ) ( s | с ) / . test ( text ) ) {
35743577 const seconds = Math . floor ( diff / second ) ;
35753578
3576- text = text . replace ( / s s | с с / , seconds < 10 ? `0${ seconds } ` : seconds ) ;
3577- text = text . replace ( / s | с / , seconds ) ;
3579+ text = text
3580+ . replace ( / (?< ! \\ ) ( s s | с с ) / g, seconds < 10 ? `0${ seconds } ` : seconds )
3581+ . replace ( / (?< ! \\ ) ( s | с ) / g, seconds ) ;
35783582
35793583 sandbox . verbose && sandbox . log ( `formatTimeDiff(format=${ format } , text=${ text } , seconds=${ seconds } )` , 'debug' ) ;
35803584
35813585 diff -= seconds * second ;
35823586 }
35833587
3588+ text = text
3589+ . replace ( / \\ ( D | T | Д ) / g, '$1' )
3590+ . replace ( / \\ ( h | S | ч ) / g, '$1' )
3591+ . replace ( / \\ ( m | м ) / g, '$1' )
3592+ . replace ( / \\ ( s | с ) / g, '$1' ) ;
3593+
35843594 sandbox . verbose && sandbox . log ( `formatTimeDiff(format=${ format } , text=${ text } )` , 'debug' ) ;
35853595
35863596 return neg ? `-${ text } ` : text ;
0 commit comments