我正在尝试计算云函数中两个时间戳之间的差异。
const diff = admin.firestore.Timestamp.now().toMillis() - licence.startDate.toMillis();
我的许可证类型包含之前设置的时间戳类型的字段 startDate。
admin.firestore.Timestamp.now().toMillis()
不会抛出此异常。
环境信息:
Operating System version: Windows 10 Home 10.0.18363 Build 18363
Firebase SDK version: 8.2.3
Node Version: 14
知道我做错了什么吗?
编辑:
License Type 的类型定义
export type Licence = {
type: LicenceType;
creationDate: Timestamp;
startDate?: Timestamp | null;
validityPeriod: number; // In Days
ownerId: string;
userVolume: number;
assistantVolume: number;
activatedUser: number;
activatedAssistant: number;
}