fixes date timezone bug
This commit is contained in:
@@ -8,9 +8,15 @@ export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const r = await pb.collection('trails')
|
||||
.getOne<Trail>(event.params.id as string, { expand: expand ?? "" })
|
||||
|
||||
// remove time from dates
|
||||
r.date = r.date?.substring(0, 10) ?? ""
|
||||
for (const log of r.expand?.summit_logs ?? []) {
|
||||
log.date = log.date.substring(0, 10)
|
||||
}
|
||||
return json(r)
|
||||
} catch (e: any) {
|
||||
throw error(e.status, e);
|
||||
} catch (e: any) {
|
||||
throw error(e.status || 500, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -263,12 +263,12 @@
|
||||
$form.duration = Math.round(
|
||||
e.target.get_total_time() / 1000 / 60,
|
||||
);
|
||||
if ($form.duration) {
|
||||
if ($form.duration && !$form.date) {
|
||||
$form.date = e.target
|
||||
.get_start_time()
|
||||
.toISOString()
|
||||
.substring(0, 10);
|
||||
} else {
|
||||
} else if(!$form.date) {
|
||||
$form.date = new Date().toISOString().substring(0, 10);
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@
|
||||
e: CustomEvent<{ text: string; value: string }>,
|
||||
) {
|
||||
if (e.detail.value === "edit") {
|
||||
summitLog.set(currentSummitLog);
|
||||
summitLog.set(currentSummitLog);
|
||||
openSummitLogModal();
|
||||
} else if (e.detail.value === "delete") {
|
||||
$form.expand.summit_logs.splice(index, 1);
|
||||
@@ -475,11 +475,12 @@
|
||||
on:change={handleFileSelection}
|
||||
/>
|
||||
<hr class="border-separator" />
|
||||
<div class="flex gap-x-4">
|
||||
<div class="flex gap-x-2">
|
||||
<h3 class="text-xl font-semibold">{$_("basic-info")}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-icon"
|
||||
style="font-size: 0.9rem"
|
||||
on:click={() => (editingBasicInfo = !editingBasicInfo)}
|
||||
><i class="fa fa-{editingBasicInfo ? 'check' : 'pen'}"
|
||||
></i></button
|
||||
@@ -554,7 +555,7 @@
|
||||
error={$errors.location}
|
||||
bind:value={$form.location}
|
||||
></TextField>
|
||||
<Datepicker label="Date" bind:value={$form.date}></Datepicker>
|
||||
<Datepicker label={$_("date")} bind:value={$form.date}></Datepicker>
|
||||
<Textarea
|
||||
name="description"
|
||||
label={$_("describe-your-trail")}
|
||||
|
||||
Reference in New Issue
Block a user