MCPcopy Create free account
hub / github.com/MathMan05/Fermi / stringToUnixTime

Function stringToUnixTime

src/webpage/snowflake.ts:9–17  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

7 return SnowFlake.stringToUnixTime(this.id);
8 }
9 static stringToUnixTime(str: string) {
10 try {
11 return Number((BigInt(str) >> 22n) + 1420070400000n);
12 } catch {
13 throw new Error(
14 `The ID is corrupted, it's ${JSON.stringify(str)} when it should be some number.`,
15 );
16 }
17 }
18 static DateToID(date: Date) {
19 return ((BigInt(+date) - 1420070400000n) << 22n).toString();
20 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected