Skip to content

Commit

Permalink
fix: use buffer to make bigint value for ticks converter
Browse files Browse the repository at this point in the history
  • Loading branch information
xxCherry authored and cyperdark committed Feb 19, 2024
1 parent a9d8f71 commit 8d7ddf9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/tosu/src/utils/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ export const netDateBinaryToDate = (
dateDataHi: number,
dateDataLo: number
): Date => {
const buffer = Buffer.alloc(8);

const ticksMask = 0x3fffffff;

dateDataHi &= ticksMask;

const dateData = (BigInt(dateDataHi) << 32n) | BigInt(dateDataLo);
buffer.writeInt32LE(dateDataLo);
buffer.writeInt32LE(dateDataHi, 4);

const dateData = buffer.readBigInt64LE();

const ticksPerMillisecond = 10000n;
const epochTicks = 621355968000000000n;
Expand Down
Empty file.
Empty file.

0 comments on commit 8d7ddf9

Please sign in to comment.