Dreamer settings — convert last dream timestamp to user local timezone
This commit is contained in:
@@ -17,6 +17,21 @@ export default function SettingsPanel() {
|
||||
const [dreaming, setDreaming] = useState(false);
|
||||
const [dreamStarted, setDreamStarted] = useState(false);
|
||||
|
||||
function formatDreamerTime(raw: string): string {
|
||||
if (!raw || raw === 'never' || raw === '—') return raw;
|
||||
try {
|
||||
// Parse "YYYY-MM-DD HH:MM" as UTC
|
||||
const utc = new Date(raw.replace(' ', 'T') + ':00Z');
|
||||
return utc.toLocaleString(undefined, {
|
||||
month: 'short', day: 'numeric',
|
||||
hour: 'numeric', minute: '2-digit',
|
||||
hour12: true,
|
||||
});
|
||||
} catch {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!settingsOpen) return;
|
||||
api.getStatus().then(setStatus).catch(console.error);
|
||||
@@ -210,7 +225,7 @@ export default function SettingsPanel() {
|
||||
<Section title="Dreamer">
|
||||
<div className="grid grid-cols-2 gap-2 mb-3">
|
||||
<StatCard number={dreamerStatus?.last_mode?.toUpperCase() || '—'} label="last mode" />
|
||||
<StatCard number={dreamerStatus?.last_dream || '—'} label="last dream" />
|
||||
<StatCard number={formatDreamerTime(dreamerStatus?.last_dream || '—')} label="last dream" />
|
||||
</div>
|
||||
<Row label="Mode">
|
||||
<select
|
||||
|
||||
Reference in New Issue
Block a user