This commit is contained in:
tree 2022-05-30 02:05:05 -05:00
rodič 5c03eb02cc
revize 86a76febd7
4 změnil soubory, kde provedl 27 přidání a 12 odebrání

Zobrazit soubor

@ -1,5 +1,5 @@
<script> <script>
import { format, formatDistanceToNow } from "date-fns"; import { formatCET } from "$lib/utils.js";
import { cs } from "date-fns/locale/index.js"; import { cs } from "date-fns/locale/index.js";
export let item; export let item;
@ -14,6 +14,6 @@
</script> </script>
<div class="font-semibold"> <div class="font-semibold">
{format(start, "yyyy-MM-dd") === "2022-06-04" ? "SO" : "NE"} {formatCET(start, "yyyy-MM-dd") === "2022-06-04" ? "SO" : "NE"}
{format(start, "HH:mm")}-{format(end, "HH:mm")} ({stage ? stage.name : "n/a"}) {formatCET(start, "HH:mm")}-{formatCET(end, "HH:mm")} ({stage ? stage.name : "n/a"})
</div> </div>

Zobrazit soubor

@ -1,5 +1,7 @@
import { format, addDays } from "date-fns"; import { format, addDays } from "date-fns";
const TZoffset = new Date().getTimezoneOffset()
export function parsePeriod(bundle, str) { export function parsePeriod(bundle, str) {
const [dayNumber, times, name] = str.split("/"); const [dayNumber, times, name] = str.split("/");
const [start, end] = times.split("-"); const [start, end] = times.split("-");
@ -10,8 +12,8 @@ export function parsePeriod(bundle, str) {
date, date,
name, name,
period: { period: {
start: new Date(`${date}T${start}`), start: new Date(`${date}T${start}+02:00`),
end: new Date(`${endDate}T${end}`), end: new Date(`${endDate}T${end}+02:00`),
}, },
}; };
} }

12
src/lib/utils.js Normal file
Zobrazit soubor

@ -0,0 +1,12 @@
import { format, compareAsc, compareDesc } from "date-fns";
const TZoffset = new Date().getTimezoneOffset()
export function formatCET (...args) {
if (TZoffset !== -120) {
const co = (120-(-TZoffset))
args[0] = new Date(args[0].getTime() + (co*60*1000))
}
return format(...args)
}

Zobrazit soubor

@ -7,6 +7,7 @@
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { page } from "$app/stores"; import { page } from "$app/stores";
import { format, compareAsc, compareDesc } from "date-fns"; import { format, compareAsc, compareDesc } from "date-fns";
import { formatCET } from '$lib/utils.js';
import { bundle, userData, loadInfo, schedulePref } from "$lib/stores.js"; import { bundle, userData, loadInfo, schedulePref } from "$lib/stores.js";
import { cs } from "date-fns/locale/index.js"; import { cs } from "date-fns/locale/index.js";
import { parsePeriod } from "$lib/periods.js"; import { parsePeriod } from "$lib/periods.js";
@ -165,7 +166,7 @@
} }
} }
} }
arr.push({ title: format(time, "HH:mm"), stages }); arr.push({ title: formatCET(time, "HH:mm"), stages });
time = new Date(time.getTime() + 30 * 60 * 1000); time = new Date(time.getTime() + 30 * 60 * 1000);
} }
return arr; return arr;
@ -407,7 +408,7 @@
{#if st.name} {#if st.name}
{st.name} {st.name}
{:else} {:else}
{format(new Date(st.date), "iiii d.M.y", { locale: cs })} {formatCET(new Date(st.date), "iiii d.M.y", { locale: cs })}
{/if} {/if}
</h2> </h2>
<div class="inline-block ml-2 text-sm font-normal my-auto print:hidden"> <div class="inline-block ml-2 text-sm font-normal my-auto print:hidden">
@ -420,7 +421,7 @@
<div <div
class="flex-1 text-right hidden sm:block float-right text-blue-web/50" class="flex-1 text-right hidden sm:block float-right text-blue-web/50"
> >
Zdrojová data: {format(new Date($bundle.time), "d.M.y H:mm")} Zdrojová data: {formatCET(new Date($bundle.time), "d.M.y H:mm")}
</div> </div>
</div> </div>
<div class="relative"> <div class="relative">
@ -432,8 +433,8 @@
<tr> <tr>
<th <th
class="xl:w-16 top-0 sticky bg-white uppercase text-sm px-0.5 text-custom-blue" class="xl:w-16 top-0 sticky bg-white uppercase text-sm px-0.5 text-custom-blue"
>{format(new Date(st.date), "iiiiii", { locale: cs })}<br >{formatCET(new Date(st.date), "iiiiii", { locale: cs })}<br
/>{format(new Date(st.date), "d.M.")}</th />{formatCET(new Date(st.date), "d.M.")}</th
> >
{#each activeStages($bundle, $bundle.spec.stages, st, plan) as stage} {#each activeStages($bundle, $bundle.spec.stages, st, plan) as stage}
{#if $schedulePref && ($schedulePref.stage === stage.id || $schedulePref.stage === "all")} {#if $schedulePref && ($schedulePref.stage === stage.id || $schedulePref.stage === "all")}
@ -487,10 +488,10 @@
> >
<div class="px-2 py-1 mb-1 mt-1"> <div class="px-2 py-1 mb-1 mt-1">
<div class="text-xs"> <div class="text-xs">
{format( {formatCET(
new Date(si.period.start), new Date(si.period.start),
"HH:mm" "HH:mm"
)}-{format(new Date(si.period.end), "HH:mm")} )}-{formatCET(new Date(si.period.end), "HH:mm")}
<span class="text-blue-web/80">@{si.id}</span> <span class="text-blue-web/80">@{si.id}</span>
{#if event.track}[{#each [$bundle.spec.tracks.find((t) => t.id === event.track)] as track}{track.shortname || {#if event.track}[{#each [$bundle.spec.tracks.find((t) => t.id === event.track)] as track}{track.shortname ||
track.name}{/each}]{/if} track.name}{/each}]{/if}