Last active
September 27, 2020 07:49
-
-
Save 2ndkauboy/27a26539436444974a009afb9cd95def to your computer and use it in GitHub Desktop.
A bookmarklet to convert time zones on a WordCamp schedule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void function(){timeZone=wp.date.__experimentalGetSettings().timezone.abbr;for(let a of document.querySelectorAll(".wcpt-time")){new Date(a.innerHTML.replace(/(\d+:\d+)( (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>`}}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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+)( (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