From 8ff5a53a9fd28902c983b88678b8c4dfe27da60d Mon Sep 17 00:00:00 2001 From: adz Date: Mon, 13 May 2024 01:36:27 +0200 Subject: [PATCH] Make sure to round all seconds down to integers --- src/components/Comments.tsx | 2 +- src/components/CreateEvent.tsx | 4 ++-- src/components/EditEvent.tsx | 2 +- src/requests.ts | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/Comments.tsx b/src/components/Comments.tsx index 6c11d2b..d60f032 100644 --- a/src/components/Comments.tsx +++ b/src/components/Comments.tsx @@ -25,7 +25,7 @@ export const Comments = ({ selected }: Props) => { createComment({ text, - created_at: DateTime.now().toSeconds(), + created_at: Math.round(DateTime.now().toSeconds()), event: selected.meta.documentId, }); diff --git a/src/components/CreateEvent.tsx b/src/components/CreateEvent.tsx index 436a97c..c1d665f 100644 --- a/src/components/CreateEvent.tsx +++ b/src/components/CreateEvent.tsx @@ -52,8 +52,8 @@ export const CreateEvent = ({ onCreated }: Props) => { title, location, description, - created_at: DateTime.now().toSeconds(), - happening_at: DateTime.fromISO(`${date}T${time}`).toSeconds(), + created_at: Math.round(DateTime.now().toSeconds()), + happening_at: Math.round(DateTime.fromISO(`${date}T${time}`).toSeconds()), }); setValues(initialValues()); diff --git a/src/components/EditEvent.tsx b/src/components/EditEvent.tsx index f26b096..2b4616d 100644 --- a/src/components/EditEvent.tsx +++ b/src/components/EditEvent.tsx @@ -64,7 +64,7 @@ export const EditEvent = ({ onUpdated, onDeleted, documentId }: Props) => { title, location, description, - happening_at: DateTime.fromISO(`${date}T${time}`).toSeconds(), + happening_at: Math.round(DateTime.fromISO(`${date}T${time}`).toSeconds()), }; return Object.keys(fields).reduce((acc, name) => { diff --git a/src/requests.ts b/src/requests.ts index d7c8755..f428036 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -62,7 +62,9 @@ export async function getAllEvents( ): Promise<{ events: Paginated; }> { - const fromTimestamp = DateTime.fromFormat(from, 'yyyy-MM-dd').toSeconds(); + const fromTimestamp = Math.round( + DateTime.fromFormat(from, 'yyyy-MM-dd').toSeconds(), + ); const toTimestamp = Math.round( DateTime.fromFormat(to, 'yyyy-MM-dd').endOf('day').toSeconds(), );