MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / toNtpSecondsAndFrac

Function toNtpSecondsAndFrac

ntp/ntp.ts:53–57  ·  view source on GitHub ↗
(ms: number)

Source from the content-addressed store, hash-verified

51
52function readNtpTimestamp(buf: Buffer, offset: number): number | undefined {
53 if (!buf || buf.length < offset + 8) return undefined;
54 const sec = buf.readUInt32BE(offset);
55 const frac = buf.readUInt32BE(offset + 4);
56 if (sec === 0 && frac === 0) return undefined; // not provided
57 const ms = (sec - NTP_EPOCH_OFFSET) * 1000 + Math.floor((frac / 2 ** 32) * 1000);
58 return ms;
59}
60

Callers 1

queryOnceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected