From 231f1078434ac97210d4abc9fefa06d0d110cd6a Mon Sep 17 00:00:00 2001 From: flaque Date: Sun, 10 Nov 2024 11:47:23 -0800 Subject: [PATCH] fix hour --- src/lib/buy/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/buy/index.tsx b/src/lib/buy/index.tsx index 5475d6b..6e04143 100644 --- a/src/lib/buy/index.tsx +++ b/src/lib/buy/index.tsx @@ -165,6 +165,16 @@ async function buyOrderAction(options: SfBuyOptions) { } function roundEndDate(endDate: Date) { + const minutes = endDate.getMinutes(); + const seconds = endDate.getSeconds(); + const ms = endDate.getMilliseconds(); + + // If already at an hour boundary (no minutes/seconds/ms), return as-is + if (minutes === 0 && seconds === 0 && ms === 0) { + return dayjs(endDate); + } + + // Otherwise round up to next hour return dayjs(endDate).add(1, "hour").startOf("hour"); }