本文整理汇总了TypeScript中src/util/convert.LongToMoment函数的典型用法代码示例。如果您正苦于以下问题:TypeScript LongToMoment函数的具体用法?TypeScript LongToMoment怎么用?TypeScript LongToMoment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LongToMoment函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: PrintTimestampDelta
export function PrintTimestampDelta(
newTimestamp: protos.cockroach.util.hlc.ITimestamp,
oldTimestamp: protos.cockroach.util.hlc.ITimestamp,
) {
if (_.isNil(oldTimestamp) || _.isNil(newTimestamp)) {
return "";
}
const newTime = LongToMoment(newTimestamp.wall_time);
const oldTime = LongToMoment(oldTimestamp.wall_time);
const diff = moment.duration(newTime.diff(oldTime));
return PrintDuration(diff);
}
示例2: PrintTimestamp
export function PrintTimestamp(
timestamp: protos.cockroach.util.hlc.ITimestamp |
protos.google.protobuf.ITimestamp,
) {
let time: moment.Moment = null;
if (_.has(timestamp, "wall_time")) {
time = LongToMoment((timestamp as protos.cockroach.util.hlc.ITimestamp).wall_time);
} else if (_.has(timestamp, "seconds") || _.has(timestamp, "nanos")) {
time = TimestampToMoment((timestamp as protos.google.protobuf.ITimestamp));
} else {
return "";
}
return PrintTime(time);
}