diff options
| author | Fuwn <[email protected]> | 2023-12-18 16:45:45 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-18 16:45:45 -0800 |
| commit | 838710942cfbe9fe696c23d71bdad9a398234a9a (patch) | |
| tree | 993fc278f5fa5f590305df7222cfd02d96c36dc5 | |
| parent | fix(schedule): off-screen clipping (diff) | |
| download | due.moe-838710942cfbe9fe696c23d71bdad9a398234a9a.tar.xz due.moe-838710942cfbe9fe696c23d71bdad9a398234a9a.zip | |
feat(schedule): timezone picker
| -rw-r--r-- | src/routes/schedule/+page.svelte | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/routes/schedule/+page.svelte b/src/routes/schedule/+page.svelte index 9868e308..6b07ea27 100644 --- a/src/routes/schedule/+page.svelte +++ b/src/routes/schedule/+page.svelte @@ -3,9 +3,16 @@ import type { SubsPlease, SubsPleaseEpisode } from '$lib/subsPlease'; import { onMount } from 'svelte'; import settings from '../../stores/settings'; + import { parseOrDefault } from '$lib/Tools/tool'; + import { browser } from '$app/environment'; let subsPleasePromise: Promise<SubsPlease>; - const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; + const urlParameters = browser ? new URLSearchParams(window.location.search) : null; + let timeZone = parseOrDefault( + urlParameters, + 'tz', + Intl.DateTimeFormat().resolvedOptions().timeZone + ); onMount( async () => (subsPleasePromise = fetch(`/api/subsplease?tz=${timeZone}`).then((r) => r.json())) @@ -43,6 +50,20 @@ {timeZone.split('/').reverse().join(', ').replace(/_/g, ' ')} </blockquote> + <p> + <select + bind:value={timeZone} + on:change={() => + (subsPleasePromise = fetch(`/api/subsplease?tz=${timeZone}`).then((r) => r.json()))} + > + {#each Intl.supportedValuesOf('timeZone') as zone} + <option value={zone}> + {zone.split('/').reverse().join(', ').replace(/_/g, ' ')} + </option> + {/each} + </select> + </p> + <div id="list-container"> {#each Object.entries(subsPlease.schedule) as [day, scheduleEntry]} <details |