Skip to content
Open
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: 2 additions & 0 deletions static/js/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const InterceptTime = (function() {
const TZ_MAP = {
'UTC': 'UTC',
'local': undefined,
'Africa/Johannesburg': 'Africa/Johannesburg',
'US/Eastern': 'America/New_York',
'US/Central': 'America/Chicago',
'US/Mountain': 'America/Denver',
Expand All @@ -72,6 +73,7 @@ const InterceptTime = (function() {
const TZ_LABELS = {
'UTC': 'UTC',
'local': '',
'Africa/Johannesburg': 'SAST',
'US/Eastern': 'ET',
'US/Central': 'CT',
'US/Mountain': 'MT',
Expand Down
11 changes: 9 additions & 2 deletions static/js/map-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,17 @@ const MapUtils = {
const clockEl = tr.querySelector('.map-hud-clock');
const dotEl = tr.querySelector('.map-hud-dot');

// Clock tick
// Clock tick — user's timezone (browser-local by default) plus UTC.
const updateClock = () => {
if (!document.body.contains(container)) return;
clockEl.textContent = new Date().toISOString().substring(11, 19) + ' UTC';
const now = new Date();
const utc = now.toISOString().substring(11, 19) + ' UTC';
// 'local' maps to no IANA zone, so getIANA() is empty for the default.
if (typeof InterceptTime !== 'undefined') {
clockEl.textContent = InterceptTime.fullTime(now) + InterceptTime.tzSuffix() + ' · ' + utc;
} else {
clockEl.textContent = utc;
}
};
updateClock();
const clockInterval = VisibleInterval.set(updateClock, 1000);
Expand Down
15 changes: 12 additions & 3 deletions static/js/modes/gps.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,10 @@ const GPS = (function() {
setText('gpsEpv', pos.epv != null ? pos.epv.toFixed(1) + ' m' : '---');
setText('gpsEps', pos.eps != null ? pos.eps.toFixed(2) + ' m/s' : '---');

// GPS time
// GPS time (InterceptTime prefs, browser-local by default; UTC if InterceptTime is absent)
if (pos.timestamp) {
const t = new Date(pos.timestamp);
setText('gpsTime', t.toISOString().replace('T', ' ').replace(/\.\d+Z$/, ' UTC'));
setText('gpsTime', formatGpsTime(t));
}

// Visuals: position panel
Expand All @@ -836,10 +836,19 @@ const GPS = (function() {
// Visuals: GPS time
if (pos.timestamp) {
const t = new Date(pos.timestamp);
setText('gpsVisTime', t.toISOString().replace('T', ' ').replace(/\.\d+Z$/, ' UTC'));
setText('gpsVisTime', formatGpsTime(t));
}
}

/** GPS fix timestamp per InterceptTime prefs (browser-local by default), UTC appended. */
function formatGpsTime(t) {
const utc = t.toISOString().replace('T', ' ').replace(/\.\d+Z$/, ' UTC');
if (typeof InterceptTime !== 'undefined') {
return InterceptTime.dateTime(t) + InterceptTime.tzSuffix() + ' (' + utc + ')';
}
return utc;
}

function updateSkyUI(sky) {
// Sidebar sat counts
setText('gpsSatUsed', sky.usat != null ? sky.usat : '-');
Expand Down
16 changes: 12 additions & 4 deletions templates/layout/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<div class="app-header-right">
{% block header_right %}
<div class="header-clock">
<span class="header-clock-label">UTC</span>
<span class="header-clock-label utc-label">UTC</span>
<span id="headerUtcTime">--:--:--</span>
</div>
{% endblock %}
Expand Down Expand Up @@ -98,15 +98,23 @@

{# Core JavaScript #}
<script>
// UTC Clock
// Header clock — InterceptTime prefs (browser-local by default), UTC if it isn't loaded
function updateUtcClock() {
const now = new Date();
const utc = now.toISOString().slice(11, 19);
const clockEl = document.getElementById('headerUtcTime');
if (clockEl) clockEl.textContent = utc;
const labelEl = document.querySelector('.header-clock-label');
if (typeof InterceptTime !== 'undefined') {
if (clockEl) clockEl.textContent = InterceptTime.fullTime(now);
if (labelEl) labelEl.textContent = InterceptTime.getLabel() || 'LOCAL';
} else if (clockEl) {
clockEl.textContent = now.toISOString().slice(11, 19);
}
}
VisibleInterval.set(updateUtcClock, 1000);
updateUtcClock();
if (typeof InterceptTime !== 'undefined') {
InterceptTime.onChange(updateUtcClock);
}

// Mobile menu toggle
const hamburgerBtn = document.getElementById('hamburgerBtn');
Expand Down
1 change: 1 addition & 0 deletions templates/partials/settings-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ <h2 id="settingsModalTitle">
<select id="globalTimezoneSelect" class="settings-select" onchange="InterceptTime.setTimezone(this.value)">
<option value="UTC">UTC</option>
<option value="local">Local (browser)</option>
<option value="Africa/Johannesburg">South Africa (SAST)</option>
<option value="US/Eastern">Eastern (ET)</option>
<option value="US/Central">Central (CT)</option>
<option value="US/Mountain">Mountain (MT)</option>
Expand Down
Loading