Fixes time zone based stuff
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import {push} from 'svelte-spa-router'
|
||||
import {fade} from 'svelte/transition'
|
||||
import {auth} from '../../lib/stores/auth.svelte'
|
||||
import {huntStatus, parseUTC} from '../../lib/utils'
|
||||
import {
|
||||
apiCreateTeam,
|
||||
apiGetHunt,
|
||||
@@ -163,13 +164,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function huntStatus(h: HuntResponse): 'ONGOING' | 'UNSTARTED' | 'CLOSED' {
|
||||
if (h.isTerminated) return 'CLOSED'
|
||||
const now = Date.now()
|
||||
if (now < new Date(h.startDateTime).getTime()) return 'UNSTARTED'
|
||||
if (now > new Date(h.endDateTime).getTime()) return 'CLOSED'
|
||||
return 'ONGOING'
|
||||
}
|
||||
|
||||
const approved = $derived(Object.values(itemStatuses).filter(s => s.itemFoundStatus === 'APPROVED').length)
|
||||
const submitted = $derived(Object.values(itemStatuses).filter(s => s.itemFoundStatus === 'SUBMITTED').length)
|
||||
@@ -414,7 +408,7 @@
|
||||
<div class="flex items-center justify-between px-4 py-3 shrink-0">
|
||||
<div>
|
||||
<p class="font-semibold text-white">{photo.hunterName}</p>
|
||||
<p class="text-xs text-white/40">{new Date(photo.photoUploadDateTime).toLocaleString()}</p>
|
||||
<p class="text-xs text-white/40">{parseUTC(photo.photoUploadDateTime).toLocaleString()}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<StatusBadge status={photo.photoStatus} />
|
||||
|
||||
Reference in New Issue
Block a user