UNPKG

@credo-ts/core

Version:

<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1

1 lines • 1.32 kB
{"version":3,"file":"timestamp.mjs","names":[],"sources":["../../src/utils/timestamp.ts"],"sourcesContent":["// Question: Spec isn't clear about the endianness. Assumes big-endian here\n// since ACA-Py uses big-endian.\nexport default function timestamp(): Uint8Array {\n let time = Date.now()\n const bytes = []\n for (let i = 0; i < 8; i++) {\n const byte = time & 0xff\n bytes.push(byte)\n time = (time - byte) / 256 // Javascript right shift (>>>) only works on 32 bit integers\n }\n return Uint8Array.from(bytes).reverse()\n}\n\n/**\n * Returns the current time in seconds\n */\nexport function nowInSeconds() {\n return Math.floor(Date.now() / 1000)\n}\n\nexport function addSecondsToDate(date: Date, seconds: number) {\n return new Date(date.getTime() + seconds * 1000)\n}\n\nexport function dateToSeconds(date: Date) {\n return Math.floor(date.getTime() / 1000)\n}\n"],"mappings":";;;AAEA,SAAwB,YAAwB;CAC9C,IAAI,OAAO,KAAK,KAAK;CACrB,MAAM,QAAQ,EAAE;AAChB,MAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC1B,MAAM,OAAO,OAAO;AACpB,QAAM,KAAK,KAAK;AAChB,UAAQ,OAAO,QAAQ;;AAEzB,QAAO,WAAW,KAAK,MAAM,CAAC,SAAS;;;;;AAMzC,SAAgB,eAAe;AAC7B,QAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;;AAGtC,SAAgB,iBAAiB,MAAY,SAAiB;AAC5D,QAAO,IAAI,KAAK,KAAK,SAAS,GAAG,UAAU,IAAK;;AAGlD,SAAgB,cAAc,MAAY;AACxC,QAAO,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK"}