Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Last active September 27, 2020 07:49
Show Gist options
  • Save 2ndkauboy/27a26539436444974a009afb9cd95def to your computer and use it in GitHub Desktop.
Save 2ndkauboy/27a26539436444974a009afb9cd95def to your computer and use it in GitHub Desktop.
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