Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A bookmarklet to convert time zones on a WordCamp schedule
timeZone = wp.date.__experimentalGetSettings().timezone.abbr;
for( let time of document.querySelectorAll('.wcpt-time') ) {
let date = new Date(time.innerHTML.replace(/(\d+:\d+)( (pm|am))?/, `${new Date().toLocaleDateString([],{ year: 'numeric', month: 'long', day: 'numeric' })} $1 $3 ${timeZone}`));
time.innerHTML = (`${time.innerHTML}<br/><span style="white-space: nowrap;">${new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit', timeZoneName:'short'})}</span>`);
}
javascript:void function(){timeZone=wp.date.__experimentalGetSettings().timezone.abbr;for(let a of document.querySelectorAll(".wcpt-time")){new Date(a.innerHTML.replace(/(\d+:\d+)(&nbsp;(pm|am))?/,`${new Date().toLocaleDateString([],{year:"numeric",month:"long",day:"numeric"})} $1 $3 ${timeZone}`));a.innerHTML=`${a.innerHTML}<br/><span style="white-space: nowrap;">${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",timeZoneName:"short"})}</span>`}}();
javascript:void function(){timeZone=window.prompt("What is the time zone of the WordCamp schedule?");for(let a of document.querySelectorAll(".wcpt-time")){let b=new Date(a.innerHTML.replace(/(\d+:\d+)(&nbsp;(pm|am))?/,`${new Date().toLocaleDateString([],{year:"numeric",month:"long",day:"numeric"})} $1 $3 ${timeZone}`));a.innerHTML=`${a.innerHTML}<br/><span style="white-space: nowrap;">${b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",timeZoneName:"short"})}</span>`}}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment