MediaWiki:Gadget-site-hackathon-zonestamp.js

/** * Display local times on Wikimedia_Hackathon_2022/Schedule, via mw:Template:Zonestamp. * * License: CC0 * * Based on  */ /* global mw */ mw.hook( 'wikipage.content' ).add( function {  if (!Array.from || !document.append ) { return; }

document.querySelectorAll( 'time.zonestamp, time.tpl-zonestamp' ).forEach( function ( node ) {   node.textContent = '';    var d = new Date( node.dateTime );    node.append( // local timezone in local language d.toLocaleString(       [], { dateStyle: 'short', timeStyle: 'short'}      ), // GMT in 24-hour en-GB format ' (',     new Date( node.dateTime ).toLocaleTimeString( 'en-GB', { timeZone: 'UTC', timeStyle: 'short' } ),      ' GMT)' ); }); });