Skip to content

Add more timezones, use 24-hr format, indicate "(next day )" if converted time is +1 day #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@

{% seo %}

{% include head_custom.html %}
{% include timezone_converter.html %}

</head>
60 changes: 0 additions & 60 deletions _includes/head_custom.html

This file was deleted.

1 change: 0 additions & 1 deletion _includes/timezone.html

This file was deleted.

95 changes: 95 additions & 0 deletions _includes/timezone_converter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<script>
function changeTimezone(toTimezone) {
var elems = document.getElementsByClassName("time");
for (let i = 0; i < elems.length; i++) {
const elem = elems[i];
let fromTimezone = elem.dataset.timezone;
if (fromTimezone === undefined) {
fromTimezone = 'PDT';
}
if (fromTimezone !== toTimezone) {
const timeText = elem.innerHTML;
let fromDateText = elem.dataset.date;
if (!fromDateText)
fromDateText = "2020-04-13";
/* conversion */
const [validFromTimezone, utcOffset] = getValidTimezone(fromTimezone);
const dateTimeString = reformatTimeString(timeText, fromDateText) + utcOffset;
const [validToTimezone,offset] = getValidTimezone(toTimezone);
const converted = new Date(dateTimeString).toLocaleString("en-GB", {timeZone: validToTimezone});
/* check date of converted time and add (next day) string to result if +1 day */
const convertedDateOnly = new Date(dateTimeString).toLocaleString("en-GB", {timeZone: validToTimezone, year:'numeric', month:'2-digit', day:'2-digit'});
let toDateText = convertedDateOnly.split('/');
toDateText = [toDateText[2], toDateText[1], toDateText[0]].join('-');
const newTimeArray = converted.split(" ")[1].split(":");
let newTime = newTimeArray[0] + ":" + newTimeArray[1];
if (toDateText > fromDateText)
newTime += " (next day)";
/* set new value */
elem.innerHTML = newTime;
elem.dataset.timezone = toTimezone;
elem.dataset.date = toDateText;
}
}
}

/*
Convert date time string into a format accepted by Date object
*/
function reformatTimeString(timeString, dateString) {
const re = /(\d?\d:\d\d)(am|pm|AM|PM)?( \(next day\))?/;
const parsed = timeString.match(re);
if (parsed) {
const hourMinArray = parsed[1].split(":");
let hour = parseInt(hourMinArray[0]);
if (parsed[2]) {
if (parsed[2].toLowerCase() === "pm") {
if (hour !== 12)
hour += 12;
}
}
const hourString = hour.toString().padStart(2, '0');
if (dateString)
return dateString + "T" + hourString + ":" + hourMinArray[1];
else
return "2020-04-13T" + hourString + ":" + hourMinArray[1];
}
else
return null
}
function getValidTimezone(timezone) {
let validTimezone = "";
let offset = "";
switch (timezone) {
case 'PDT':
validTimezone = "America/Los_Angeles";
offset = "-07:00";
break;
case 'EDT':
validTimezone = "America/New_York";
offset = "-04:00";
break;
case 'CEST':
validTimezone = "Europe/Amsterdam";
offset = "+02:00";
break;
case 'CST':
validTimezone = "Asia/Hong_Kong";
offset = "+08:00";
break;
case 'MST':
validTimezone = "America/Denver";
offset = "-06:00";
break;
case 'BST':
validTimezone = "Europe/London";
offset = "+01:00";
break;
case 'IST':
validTimezone = "Asia/Kolkata";
offset = "+05:30";
break;
}
return [validTimezone, offset];
}
</script>
8 changes: 6 additions & 2 deletions workshops/EEGLAB_2021_UCSD.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Below is a still-provisional program for the 2021 Virtual EEGLAB Workshop (sugge
<button onclick="changeTimezone('PDT')" style="background-color: #4CAF50; color: white; border: none; padding: 5px 5px; text-align: center;">PDT</button>
<button onclick="changeTimezone('EDT')" style="background-color: #008CBA; color: white; border: none; padding: 5px 5px; text-align: center;">EDT</button>
<button onclick="changeTimezone('CEST')" style="background-color:Orange; color: white; border: none; padding: 5px 5px; text-align: center;">CEST</button>
<button onclick="changeTimezone('CST')" style="background-color: #ebcf34; color: white; border: none; padding: 5px 5px; text-align: center;">CST</button>
<button onclick="changeTimezone('MST')" style="background-color:#34bdeb; color: white; border: none; padding: 5px 5px; text-align: center;">MST</button>
<button onclick="changeTimezone('BST')" style="background-color:Grey; color: white; border: none; padding: 5px 5px; text-align: center;">BST</button>
<button onclick="changeTimezone('IST')" style="background-color:Purple; color: white; border: none; padding: 5px 5px; text-align: center;">IST</button>

## MONDAY, June 14th (open to all; free registration required)

Expand Down Expand Up @@ -105,7 +109,7 @@ Below is a still-provisional program for the 2021 Virtual EEGLAB Workshop (sugge

## WEDNESDAY, June 16th (paid registration required)

- <span style="color: black">7:00am7:45 – **ICA decomposition PRACTICUM** (Johanna Wagner)</span>
- <span style="color: black"><span class="time" data-timezone="PDT">7:00am</span>–<span class="time" data-timezone="PDT">7:45</span> – **ICA decomposition PRACTICUM** (Johanna Wagner)</span>

- <span style="color: black"><span class="time" data-timezone="PDT">8:00am</span>–<span class="time" data-timezone="PDT">9:00</span> – **Forward &amp; inverse head modeling** (Zeynep Aakalin Acar)</span>

Expand Down Expand Up @@ -133,7 +137,7 @@ Below is a still-provisional program for the 2021 Virtual EEGLAB Workshop (sugge

## THURSDAY, June 17th (paid registration required)

- <span style="color: black">7:00am7:45 – **ICA clustering PRACTICUM** (Julie Onton)</span>
- <span style="color: black"><span class="time" data-timezone="PDT">7:00am</span>–<span class="time" data-timezone="PDT">7:45</span> – **ICA clustering PRACTICUM** (Julie Onton)</span>

- <span style="color: black"><span class="time" data-timezone="PDT">8:00am</span>-<span class="time" data-timezone="PDT">9:00</span> – **EEGLAB group analysis** (Arnaud Delorme)</span>

Expand Down