Skip to content

Commit

Permalink
Make sure to round all seconds down to integers
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed May 12, 2024
1 parent b7dd9a1 commit 8ff5a53
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/CreateEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export async function getAllEvents(
): Promise<{
events: Paginated<Event>;
}> {
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(),
);
Expand Down

0 comments on commit 8ff5a53

Please sign in to comment.