up
This commit is contained in:
@@ -94,6 +94,11 @@ function toLocalISO(d: any): string {
|
||||
if (!d) return '';
|
||||
const date = new Date(d);
|
||||
if (isNaN(date.getTime())) return '';
|
||||
// Go's zero time.Time serialises as "0001-01-01T00:00:00Z" (json omitempty
|
||||
// doesn't apply to a time struct), so a QSO with no end time arrives as a
|
||||
// year-1 date. Treat anything that old as unset — otherwise the datetime
|
||||
// field shows a garbage value and fights the user's typing.
|
||||
if (date.getUTCFullYear() <= 1) return '';
|
||||
const p = (n: number) => String(n).padStart(2, '0');
|
||||
return `${date.getUTCFullYear()}-${p(date.getUTCMonth()+1)}-${p(date.getUTCDate())}T${p(date.getUTCHours())}:${p(date.getUTCMinutes())}`;
|
||||
}
|
||||
@@ -159,8 +164,9 @@ export function QSOEditModal({ qso, onSave, onDelete, onClose, countries = [], b
|
||||
const [freqRxKHz, setFreqRxKHz] = useState(fr0.khz);
|
||||
const [freqRxHz, setFreqRxHz] = useState(fr0.hz);
|
||||
const [dateOn, setDateOn] = useState(toLocalISO(draft.qso_date));
|
||||
const [dateOff, setDateOff] = useState(toLocalISO(draft.qso_date_off));
|
||||
const [endEnabled, setEndEnabled] = useState(!!draft.qso_date_off);
|
||||
const dateOffISO = toLocalISO(draft.qso_date_off); // '' when unset / Go zero time
|
||||
const [dateOff, setDateOff] = useState(dateOffISO);
|
||||
const [endEnabled, setEndEnabled] = useState(!!dateOffISO);
|
||||
const [confSel, setConfSel] = useState('QSL'); // selected confirmation channel
|
||||
const [localErr, setLocalErr] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
@@ -428,7 +434,13 @@ export function QSOEditModal({ qso, onSave, onDelete, onClose, countries = [], b
|
||||
<div><Label>QSO Start (UTC)</Label><Input type="datetime-local" value={dateOn} onChange={(e) => setDateOn(e.target.value)} /></div>
|
||||
<div>
|
||||
<Label className="flex items-center gap-2">
|
||||
<Checkbox checked={endEnabled} onCheckedChange={(c) => setEndEnabled(!!c)} /> QSO End (UTC)
|
||||
<Checkbox checked={endEnabled} onCheckedChange={(c) => {
|
||||
const on = !!c;
|
||||
setEndEnabled(on);
|
||||
// Prefill an empty end with the start time so the user
|
||||
// only tweaks the minutes instead of typing a full date.
|
||||
if (on && !dateOff) setDateOff(dateOn);
|
||||
}} /> QSO End (UTC)
|
||||
</Label>
|
||||
<Input type="datetime-local" value={dateOff} disabled={!endEnabled} onChange={(e) => setDateOff(e.target.value)} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user