core: feat: problem_delete

This commit is contained in:
undefined committed 2021-01-11 23:01:00 +08:00
1 parent 3d9acf2c1a
commit 1543a374e3
12 files changed
+151 -174

No files matched your search

+13
View File
@@ -4,6 +4,9 @@ import cluster from 'cluster';
import path from 'path';
import serialize from 'serialize-javascript';
import Lru from 'lru-cache';
import { ObjectID } from 'mongodb';
import { isMoment } from 'moment';
import { Moment } from 'moment-timezone';
declare global {
interface StringConstructor {
@@ -240,4 +243,14 @@ export namespace Time {
}
return `${ms}ms`;
}
export function getObjectID(timestamp: string | Date | Moment) {
let _timestamp: number;
if (typeof timestamp === 'string') _timestamp = new Date(timestamp).getTime();
else if (isMoment(timestamp)) _timestamp = timestamp.toDate().getTime();
else _timestamp = timestamp.getTime();
const hexSeconds = Math.floor(_timestamp / 1000).toString(16);
const constructedObjectId = new ObjectID(`${hexSeconds}0000000000000000`);
return constructedObjectId;
}
}