Skip to content

Commit

Permalink
Allow specific timezone for timezone label
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Jan 19, 2024
1 parent b78df14 commit 7569f15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion _includes/scripts/time_localizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ document.addEventListener("DOMContentLoaded", function() {
});

document.querySelectorAll('.timezone').forEach(function(el) {
var targetTimeZone = el.getAttribute('totimezone') || undefined;
var sourceTime = el.getAttribute('time') && parseInt(el.getAttribute('time') + '000');
var date = (sourceTime && new Date(sourceTime)) || new Date();
el.textContent = date.toLocaleDateString(undefined, {day:'2-digit',timeZoneName: 'long' }).substring(4);
el.textContent = date.toLocaleDateString(undefined, {
day:'2-digit',
timeZoneName: 'long',
timeZone: targetTimeZone,
}).substring(4);
});

function parseTime(t) {
Expand Down

0 comments on commit 7569f15

Please sign in to comment.