@@ -1442,6 +1442,25 @@ const configTwig = function() {
14421442 return date . replace ( " " , "T" ) ;
14431443 } ) ;
14441444
1445+ globalThis . Twig . extendFunction ( 'rfc822_datetime' , ( date ) => {
1446+ const dateString = date . replace ( " " , "T" ) ;
1447+
1448+ const dayStrings = [ "Sun" , "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" ] ;
1449+ const monthStrings = [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ] ;
1450+
1451+ const timeStamp = Date . parse ( dateString ) ;
1452+ const date = new Date ( timeStamp ) ;
1453+
1454+ const day = dayStrings [ date . getDay ( ) ] ;
1455+ const dayNumber = addLeadingZero ( date . getDate ( ) ) ;
1456+ const month = monthStrings [ date . getMonth ( ) ] ;
1457+ const year = date . getFullYear ( ) ;
1458+ const time = `${ addLeadingZero ( date . getHours ( ) ) } :${ addLeadingZero ( date . getMinutes ( ) ) } :00` ;
1459+ const timezone = date . getTimezoneOffset ( ) === 0 ? "GMT" : "BST" ;
1460+
1461+ return `${ day } , ${ dayNumber } ${ month } ${ year } ${ time } ${ timezone } ` ;
1462+ } ) ;
1463+
14451464 globalThis . Twig . extendFunction ( 'reference' , ( articleUri , pos ) => {
14461465 return references_cache [ articleUri + "/" + pos ] ;
14471466 } ) ;
@@ -1606,6 +1625,12 @@ const configTwig = function() {
16061625 } ) ;
16071626}
16081627
1628+ const addLeadingZero = function ( num ) {
1629+ let numStr = num . toString ( ) ;
1630+ while ( numStr . length < 2 ) numStr = "0" + numStr ;
1631+ return numStr ;
1632+ }
1633+
16091634const generateRandomId = function ( ) {
16101635 return Date . now ( ) . toString ( 36 ) + Math . floor ( Math . random ( ) * 100000 ) . toString ( 36 ) ;
16111636}
0 commit comments