on bd2bfea help sign in
bridge/src/lib/utils/roller.ts
16 lines 551 B history raw
1export const SECOND = 1000;
2export const MINUTE = SECOND * 60;
3export const HOUR = MINUTE * 60;
5export const padZero = (amount: number) => `${amount < 10 ? '0' : ''}${amount}`;
7export const getTimeToNextBatch = (nextBatch: number, now: number) => {
8 const toNext = nextBatch - now;
9 const hours = Math.floor(toNext / HOUR);
10 const minutes = Math.floor((toNext - hours * HOUR) / MINUTE);
11 const seconds = Math.floor(
12 (toNext - hours * HOUR - minutes * MINUTE) / SECOND
13 );
15 return `${hours}h ${padZero(minutes)}m ${padZero(seconds)}s`;
16};