2025-02-12 00:00:14 +00:00
|
|
|
<script lang="ts">
|
2026-07-28 16:16:26 +00:00
|
|
|
import {formatTimestamp, formatTimestampAsDate, formatTimestampAsTime} from "@welshman/lib"
|
2025-02-12 00:00:14 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {tagSpec, tagValue} from "@welshman/util"
|
|
|
|
|
import {TimeEvent} from "@welshman/domain"
|
2025-09-10 22:26:39 +00:00
|
|
|
import ClockCircle from "@assets/icons/clock-circle.svg?dataurl"
|
2025-02-12 00:00:14 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {reader} from "@app/core"
|
2025-02-12 00:00:14 +00:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {event}: Props = $props()
|
2026-07-28 16:16:26 +00:00
|
|
|
|
|
|
|
|
const timeEvent = reader(TimeEvent)(event)
|
|
|
|
|
|
|
|
|
|
// NIP-52 settled on `title`, but events from before that still carry `name`.
|
|
|
|
|
const title = $derived(timeEvent.title() ?? tagValue(tagSpec("name"), event.tags))
|
|
|
|
|
const start = timeEvent.start()
|
|
|
|
|
const end = timeEvent.end()
|
2025-02-12 00:00:14 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-05-07 00:24:29 +00:00
|
|
|
<div class="flex flex-col justify-between gap-1">
|
2026-07-28 16:16:26 +00:00
|
|
|
<p class="text-lg">{title}</p>
|
|
|
|
|
{#if start && end}
|
|
|
|
|
{@const isSingleDay = formatTimestampAsDate(start) === formatTimestampAsDate(end)}
|
2026-05-07 00:24:29 +00:00
|
|
|
<div class="flex flex-wrap gap-2 text-xs">
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<Icon icon={ClockCircle} size={4} />
|
|
|
|
|
{formatTimestampAsDate(start)}
|
|
|
|
|
</div>
|
2025-10-06 18:23:19 +00:00
|
|
|
{formatTimestampAsTime(start)} — {isSingleDay
|
|
|
|
|
? formatTimestampAsTime(end)
|
|
|
|
|
: formatTimestamp(end)}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2025-02-12 00:00:14 +00:00
|
|
|
</div>
|