UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

16 lines (14 loc) 385 B
import { google } from './model' /** * Converts a protobuf timestamp into a Javascript Date * * ```typescript * utils.timestampToDate(timestamp); * ``` */ export function timestampToDate(timestamp?: google.protobuf.ITimestamp) { const milliseconds: number = timestamp ? (timestamp.seconds as number) * 1e3 + timestamp.nanos / 1e6 : 0 return new Date(milliseconds) }