Skip to content

Commit

Permalink
fix hour
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaque committed Nov 10, 2024
1 parent cdc10c1 commit 231f107
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/buy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit 231f107

Please sign in to comment.