@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
27 lines (26 loc) • 667 B
JavaScript
//#region src/utils/timestamp.ts
function timestamp() {
let time = Date.now();
const bytes = [];
for (let i = 0; i < 8; i++) {
const byte = time & 255;
bytes.push(byte);
time = (time - byte) / 256;
}
return Uint8Array.from(bytes).reverse();
}
/**
* Returns the current time in seconds
*/
function nowInSeconds() {
return Math.floor(Date.now() / 1e3);
}
function addSecondsToDate(date, seconds) {
return new Date(date.getTime() + seconds * 1e3);
}
function dateToSeconds(date) {
return Math.floor(date.getTime() / 1e3);
}
//#endregion
export { addSecondsToDate, dateToSeconds, timestamp as default, nowInSeconds };
//# sourceMappingURL=timestamp.mjs.map