Skip to content

Instantly share code, notes, and snippets.

@lolmaus
Last active March 30, 2021 16:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lolmaus/52b6132c8c235e464328e194406fa84e to your computer and use it in GitHub Desktop.
Save lolmaus/52b6132c8c235e464328e194406fa84e to your computer and use it in GitHub Desktop.
EmberConf 2021 companion app timezone converter. Open the Schedule page in the companion app, paste this code snippet into the Dev Tools console., change your time zone (first line) and run
yourTimeZoneUtc = 3;
emberConfTimeZoneUtc = -7;
//////////
function getTime(str) {
const [_str, hoursRawStr, minutesStr, amPm] = /(\d+):(\d+) (\w+)/.exec(str);
const hoursRaw = parseInt(hoursRawStr, 10);
const isPm = amPm === 'PM';
// https://stackoverflow.com/a/15083891/901944
const hours =
(isPm && hoursRaw < 12) ? hoursRaw + 12 :
(!isPm && hoursRaw === 12) ? 0 :
hoursRaw;
const hoursNew = (hours + yourTimeZoneUtc - emberConfTimeZoneUtc + 24) % 24;
return `${hoursNew}:${minutesStr}`;
}
/////////
function changeTime(element) {
const newTime = getTime(element.textContent.trim());
element.textContent = newTime;
}
/////////
Array
.from(document.querySelectorAll('.full-schedule-item__time'))
.forEach(element => {
changeTime(element.children[0]);
changeTime(element.children[1]);
});

BSD Zero Clause License (public-domain-equivalent)

Copyright (C) 2021 by Andrey Mikhaylov (lolmaus) lolmaus@gmail.com

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

I maked these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment