Fixes time zone based stuff

This commit is contained in:
2026-05-18 20:59:55 -05:00
parent aae0c3ff8d
commit 1772081495
7 changed files with 38 additions and 47 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import {push} from 'svelte-spa-router'
import {auth} from '../../lib/stores/auth.svelte'
import {huntStatus, formatDateTime} from '../../lib/utils'
import {
apiCreateTeam,
apiGetHunterTeam,
@@ -127,19 +128,6 @@
// ── Helpers ──────────────────────────────────────────────────────────────────
function huntStatus(hunt: HuntResponse): 'ONGOING' | 'UNSTARTED' | 'CLOSED' {
if (hunt.isTerminated) return 'CLOSED'
const now = Date.now()
const start = new Date(hunt.startDateTime).getTime()
const end = new Date(hunt.endDateTime).getTime()
if (now < start) return 'UNSTARTED'
if (now > end) return 'CLOSED'
return 'ONGOING'
}
function formatDate(dt: string) {
return new Date(dt).toLocaleDateString(undefined, { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })
}
</script>
<div class="p-4 pb-20">
@@ -184,7 +172,7 @@
<StatusBadge status={huntStatus(hunt)} />
</div>
<p class="text-xs text-base-content/50">
{formatDate(hunt.startDateTime)} {formatDate(hunt.endDateTime)}
{formatDateTime(hunt.startDateTime)} {formatDateTime(hunt.endDateTime)}
</p>
</div>
</button>
@@ -212,7 +200,7 @@
<StatusBadge status={huntStatus(hunt)} />
</div>
<p class="text-xs text-base-content/50">
{formatDate(hunt.startDateTime)} {formatDate(hunt.endDateTime)}
{formatDateTime(hunt.startDateTime)} {formatDateTime(hunt.endDateTime)}
</p>
{#if myTeam}
<p class="text-sm font-medium text-primary">Team: {myTeam.name}</p>
@@ -236,7 +224,7 @@
<div class="p-4 border-b border-base-200 flex items-center justify-between sticky top-0 bg-base-100">
<div>
<h3 class="font-bold text-lg">{sheetHunt.title}</h3>
<p class="text-xs text-base-content/50">{formatDate(sheetHunt.startDateTime)} {formatDate(sheetHunt.endDateTime)}</p>
<p class="text-xs text-base-content/50">{formatDateTime(sheetHunt.startDateTime)} {formatDateTime(sheetHunt.endDateTime)}</p>
</div>
<button class="btn btn-ghost btn-sm btn-circle" onclick={closeSheet}>✕</button>
</div>