UNPKG

@standard-crypto/farcaster-js-hub-rest

Version:

A tool for interacting with the REST API of any Farcaster hub.

29 lines 946 B
"use strict"; /** * Utilities for interacting with serialized timestamps in the * Farcaster protocol. See [Farcaster docs](https://github.com/farcasterxyz/protocol/blob/main/docs/SPECIFICATION.md#timestamps) * for more information. * @module */ Object.defineProperty(exports, "__esModule", { value: true }); exports.serialize = exports.parse = exports.START = void 0; exports.START = new Date('01 Jan 2021 00:00:00 UTC'); /** * Parses a Farcaster timestamp * @param timestamp seconds since Jan 1, 2021 00:00:00UTC * @returns */ function parse(timestamp) { return new Date(exports.START.getTime() + timestamp * 1000); } exports.parse = parse; /** * Serialized a timestamp to seconds since the Farcaster epoch * @param d timestamp as a Date instance * @returns */ function serialize(d) { return (d.getTime() - exports.START.getTime()) / 1000; } exports.serialize = serialize; //# sourceMappingURL=farcasterEpochTimestamp.js.map