Skip to content

Commit

Permalink
fix sf buy (#33)
Browse files Browse the repository at this point in the history
* buy

* check-fix

* sf buy start time now

* fmt
  • Loading branch information
Sladuca authored Oct 3, 2024
1 parent 283bc58 commit 2eea48d
Show file tree
Hide file tree
Showing 3 changed files with 328 additions and 162 deletions.
11 changes: 11 additions & 0 deletions src/helpers/units.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dayjs from "dayjs";
import type { Nullable } from "../types/empty";

// -- time
Expand Down Expand Up @@ -25,6 +26,16 @@ export function roundStartDate(startDate: Date): Date {
}
}

export function computeApproximateDurationSeconds(
startDate: Date | "NOW",
endDate: Date,
): number {
const startEpoch =
startDate === "NOW" ? currentEpoch() : dateToEpoch(startDate);
const endEpoch = dateToEpoch(endDate);
return dayjs(epochToDate(endEpoch)).diff(dayjs(epochToDate(startEpoch)), "s");
}

export function roundEndDate(endDate: Date): Date {
return epochToDate(roundEpochUpToHour(dateToEpoch(endDate)));
}
Expand Down
Loading

0 comments on commit 2eea48d

Please sign in to comment.