Skip to content

Commit

Permalink
add millis time module
Browse files Browse the repository at this point in the history
  • Loading branch information
bendn committed Feb 21, 2024
1 parent d8b43f1 commit 5077269
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ import {
GET_LATEST_BLOCKS,
GET_LATEST_TRANSACTIONS,
} from "@/graphql/queries";
import { day } from "@/lib/millis";

function frequency(d: Date[]): number[] {
let map = Array<number>(30).fill(0);
d.forEach(
(date) =>
(map[
29 -
Math.round(
Math.abs((date.getTime() - new Date().getTime()) / 0x5265c00)
)
] += 1)
(map[
29 -
Math.round(
Math.abs((date.getTime() - new Date().getTime()) / day)
)
] += 1)
);
return map;
}
Expand Down Expand Up @@ -276,14 +277,14 @@ const LastMonthsTransfers: React.FC = () => {
callback: (x) =>
x == 2 || x == 15 || x == 27
? (() => {
const date = new Date(
when.getTime() + 0x5265c00 * Number(x)
);
return date.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
})()
const date = new Date(
when.getTime() + day * Number(x)
);
return date.toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
})()
: undefined,
},
},
Expand Down
4 changes: 4 additions & 0 deletions src/lib/millis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const second = 1000;
export const minute = second * 60;
export const hour = minute * 60;
export const day = hour * 24;

0 comments on commit 5077269

Please sign in to comment.