Skip to content
Merged
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
17 changes: 15 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,12 @@ <h1 class="event-name" id="cd-name"></h1>
})();
const DETECTED_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone;

// Cities with no IANA zone of their own (e.g. Dallas uses America/Chicago)
// but that people search by city name.
const CITY_ALIASES = {
'america/chicago': ['dallas'],
};

function tzOffsetLabel(tz) {
try {
const fmt = new Intl.DateTimeFormat('en-US', { timeZone: tz, timeZoneName: 'shortOffset' });
Expand Down Expand Up @@ -1187,12 +1193,19 @@ <h1 class="event-name" id="cd-name"></h1>
list.innerHTML = '';
const q = (filter || '').toLowerCase();
const filtered = q
? ALL_TIMEZONES.filter(tz => tz.toLowerCase().includes(q) || tzOffsetLabel(tz).toLowerCase().includes(q))
? ALL_TIMEZONES.filter(tz => {
const key = tz.toLowerCase();
return key.includes(q) || tzOffsetLabel(tz).toLowerCase().includes(q) ||
(CITY_ALIASES[key] || []).some(alias => alias.includes(q));
})
: ALL_TIMEZONES;
filtered.slice(0, 50).forEach(tz => {
const li = document.createElement('li');
li.className = 'tz-option' + (tz === selectedTz ? ' active' : '');
li.textContent = tzFriendlyName(tz);
const matchedAlias = q && (CITY_ALIASES[tz.toLowerCase()] || []).find(alias => alias.includes(q));
li.textContent = matchedAlias
? `${tzFriendlyName(tz)} — ${matchedAlias.replace(/\b\w/g, c => c.toUpperCase())}`
: tzFriendlyName(tz);
li.addEventListener('click', (e) => {
e.stopPropagation();
selectedTz = tz;
Expand Down
Loading