Dreamer schedule — show local time, convert to UTC on save
This commit is contained in:
@@ -280,15 +280,27 @@ export default function SettingsPanel() {
|
|||||||
{dreaming ? 'Starting...' : dreamStarted ? 'Started ✓' : 'Dream'}
|
{dreaming ? 'Starting...' : dreamStarted ? 'Started ✓' : 'Dream'}
|
||||||
</SBtn>
|
</SBtn>
|
||||||
</Row>
|
</Row>
|
||||||
<Row label="Nightly schedule (UTC)" desc="Hour the dreamer fires automatically">
|
<Row label="Nightly schedule" desc="Hour the dreamer fires automatically (your local time)">
|
||||||
<select
|
<select
|
||||||
value={settings.dream_hour_utc ?? 8}
|
value={(() => {
|
||||||
onChange={e => updateSetting('dream_hour_utc', parseInt(e.target.value))}
|
// Convert stored UTC hour to local hour for display
|
||||||
|
const utcHour = settings.dream_hour_utc ?? 8;
|
||||||
|
const d = new Date();
|
||||||
|
d.setUTCHours(utcHour, 0, 0, 0);
|
||||||
|
return d.getHours();
|
||||||
|
})()}
|
||||||
|
onChange={e => {
|
||||||
|
// Convert local hour to UTC for storage
|
||||||
|
const localHour = parseInt(e.target.value);
|
||||||
|
const d = new Date();
|
||||||
|
d.setHours(localHour, 0, 0, 0);
|
||||||
|
updateSetting('dream_hour_utc', d.getUTCHours());
|
||||||
|
}}
|
||||||
className="rounded-md px-2 py-1 text-sm"
|
className="rounded-md px-2 py-1 text-sm"
|
||||||
style={{ background: 'var(--bg3)', border: '1px solid var(--border2)', color: 'var(--text)', fontFamily: 'var(--font-sans)' }}
|
style={{ background: 'var(--bg3)', border: '1px solid var(--border2)', color: 'var(--text)', fontFamily: 'var(--font-sans)' }}
|
||||||
>
|
>
|
||||||
{Array.from({length: 24}, (_, i) => (
|
{Array.from({length: 24}, (_, i) => (
|
||||||
<option key={i} value={i}>{i.toString().padStart(2,'0')}:00 UTC</option>
|
<option key={i} value={i}>{i.toString().padStart(2,'0')}:00</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
Reference in New Issue
Block a user