Add global timezone/12h-24h setting and improve satellite selection

Global time preferences (Settings > Display > Time & Timezone):
- InterceptTime utility in core/utils.js with timezone + 12h/24h support
- Timezone options: UTC, Local, Eastern, Central, Mountain, Pacific
- Time format: 12-hour (AM/PM) or 24-hour toggle
- Defaults to US/Eastern + 12-hour
- Header nav clock updates to use selected timezone and format
- Weather satellite mode delegates to global InterceptTime
- Settings persist via localStorage, change listeners notify all modes

Weather satellite improvements:
- Satellite dropdown defaults to "All Meteor Satellites" showing all passes
- Can still filter to specific satellite (M2-3, M2-4, M2-4-80K)
- Capture button on pass cards auto-selects the correct satellite

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
mitchross
2026-03-25 01:24:42 -04:00
parent 1e5bc0054d
commit ebc838fa9d
6 changed files with 191 additions and 73 deletions
+108
View File
@@ -55,6 +55,114 @@ function isValidChannel(ch) {
// ============== TIME FORMATTING ==============
/**
* Global time preferences — timezone and 12h/24h format.
* Stored in localStorage, used by all modes.
*/
const InterceptTime = (function() {
const TZ_MAP = {
'UTC': 'UTC',
'local': undefined,
'US/Eastern': 'America/New_York',
'US/Central': 'America/Chicago',
'US/Mountain': 'America/Denver',
'US/Pacific': 'America/Los_Angeles',
};
const TZ_LABELS = {
'UTC': 'UTC',
'local': '',
'US/Eastern': 'ET',
'US/Central': 'CT',
'US/Mountain': 'MT',
'US/Pacific': 'PT',
};
let _timezone = localStorage.getItem('interceptTimezone') || 'US/Eastern';
let _hour12 = (localStorage.getItem('interceptHour12') || 'true') === 'true';
const _listeners = [];
function getTimezone() { return _timezone; }
function getHour12() { return _hour12; }
function getIANA() { return TZ_MAP[_timezone]; }
function getLabel() { return TZ_LABELS[_timezone] || ''; }
function setTimezone(tz) {
if (!TZ_MAP.hasOwnProperty(tz)) return;
_timezone = tz;
localStorage.setItem('interceptTimezone', tz);
// Migrate weather-sat specific key
localStorage.setItem('wxsatTimezone', tz);
_notify();
}
function setHour12(val) {
_hour12 = !!val;
localStorage.setItem('interceptHour12', _hour12 ? 'true' : 'false');
_notify();
}
function onChange(fn) { _listeners.push(fn); }
function _notify() { _listeners.forEach(fn => { try { fn(); } catch(e) { console.error(e); } }); }
/**
* Format a Date or ISO string for the global timezone.
* @param {Date|string} input - Date object or ISO string
* @param {object} [extraOpts] - Additional Intl.DateTimeFormat options
* @returns {string}
*/
function format(input, extraOpts) {
if (!input) return '--';
try {
const date = typeof input === 'string' ? new Date(input) : input;
if (isNaN(date.getTime())) return typeof input === 'string' ? input : '--';
const opts = { hour12: _hour12, ...extraOpts };
const iana = getIANA();
if (iana) opts.timeZone = iana;
return date.toLocaleString(undefined, opts);
} catch { return typeof input === 'string' ? input : '--'; }
}
/** HH:MM (or h:MM AM/PM) */
function shortTime(input) {
return format(input, { hour: '2-digit', minute: '2-digit' });
}
/** HH:MM:SS */
function fullTime(input) {
return format(input, { hour: '2-digit', minute: '2-digit', second: '2-digit' });
}
/** Mon 25, 14:30 (or 2:30 PM) */
function dateTime(input) {
return format(input, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' });
}
/** Mon 25, 2026 */
function dateOnly(input) {
const iana = getIANA();
const opts = { year: 'numeric', month: 'short', day: 'numeric' };
if (iana) opts.timeZone = iana;
try {
const date = typeof input === 'string' ? new Date(input) : input;
return date.toLocaleDateString(undefined, opts);
} catch { return '--'; }
}
/** Short label like " ET" or " UTC" for appending to times */
function tzSuffix() {
const l = getLabel();
return l ? ' ' + l : '';
}
return {
getTimezone, getHour12, getIANA, getLabel,
setTimezone, setHour12, onChange,
format, shortTime, fullTime, dateTime, dateOnly, tzSuffix,
TZ_MAP, TZ_LABELS,
};
})();
/**
* Get relative time string from timestamp
* @param {string} timestamp - Time string in HH:MM:SS format