mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: feat: problem_delete
This commit is contained in:
1 parent
3d9acf2c1a
commit
1543a374e3
12 files changed
+151
-174
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user