vega-frontend-monorepo/libs/react-helpers/src/lib/time.ts
2022-11-04 10:47:39 +00:00

10 lines
305 B
TypeScript

export const toNanoSeconds = (date: Date | string) => {
return new Date(date).getTime().toString() + '000000';
};
export const fromNanoSeconds = (ts: string) => {
if (typeof ts !== 'string') return new Date(0);
const validTs = ts.substring(0, ts.length - 6);
return new Date(Number(validTs));
};