From e75f7121458814fc5057eeb47d9b85b4efdb585c Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Wed, 19 Jul 2023 16:42:08 -0700 Subject: [PATCH] Fix date drift and some display bugs --- src/App.svelte | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index e406dae..6168b35 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -20,7 +20,10 @@ days: getDaysInMonth(date.getFullYear(), date.getMonth()), }) - const fromNostrTime = seconds => new Date(seconds * 1000).toISOString().slice(0, -5).split("T") + + const getTimezoneOffset = () => new Date().getTimezoneOffset() * 60000 + + const fromNostrTime = seconds => new Date(seconds * 1000 - getTimezoneOffset()).toISOString().slice(0, -5).split("T") const toNostrTime = (date, time) => dateToSeconds(new Date(`${date}T${time}`)).toString() @@ -167,7 +170,7 @@ await event.publish() - events = events.filter(e => e.id !== event.id).concat(event) + events = events.filter(e => getMeta(e).d !== draft.id).concat(event) key = Math.random() draft = null @@ -198,7 +201,7 @@ if (confirm("Are you sure you want to delete this event?")) { await draft.event.delete() - events = events.filter(e => e.id !== event.id) + events = events.filter(e => getMeta(e).d !== draft.id) key = Math.random() draft = null @@ -229,7 +232,7 @@
{#key key} {#each month.days as date, i} -
+
{date.getDate()} @@ -238,17 +241,18 @@ {@const meta = getMeta(event)} {@const isContinuation = eventIsInRange(changeDay(date, -1), event)} {@const isContinued = eventIsInRange(changeDay(date, 1), event)} + {@const isOwn = event.pubkey === user?.hexpubkey()}