Improve performance a bit

This commit is contained in:
Jon Staab
2024-12-09 14:03:59 -08:00
parent 880093296e
commit ea0e1a6c9a
4 changed files with 35 additions and 48 deletions
+4 -6
View File
@@ -1,17 +1,13 @@
<script lang="ts">
import {fromPairs} from "@welshman/lib"
import {secondsToDate, getLocale, formatTimestamp, formatTimestampAsDate} from "@welshman/app"
import {formatTimestamp, formatTimestampAsDate, formatTimestampAsTime} from "@welshman/app"
import Icon from "@lib/components/Icon.svelte"
export let event
const timeFmt = new Intl.DateTimeFormat(getLocale(), {timeStyle: "short"})
$: meta = fromPairs(event.tags) as Record<string, string>
$: end = parseInt(meta.end)
$: start = parseInt(meta.start)
$: startDate = secondsToDate(start)
$: endDate = secondsToDate(end)
$: startDateDisplay = formatTimestampAsDate(start)
$: endDateDisplay = formatTimestampAsDate(end)
$: isSingleDay = startDateDisplay === endDateDisplay
@@ -21,6 +17,8 @@
<span>{meta.title || meta.name}</span>
<div class="flex items-center gap-2 text-sm">
<Icon icon="clock-circle" size={4} />
{timeFmt.format(startDate)}{isSingleDay ? timeFmt.format(endDate) : formatTimestamp(end)}
{formatTimestampAsTime(start)}{isSingleDay
? formatTimestampAsTime(end)
: formatTimestamp(end)}
</div>
</div>