mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: update to mongodb5 (#514)
This commit is contained in:
1 parent
5a02010120
commit
0685b88066
59 files changed
+610
-601
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import AnsiUp from 'ansi_up';
|
||||
import { moment, ObjectID } from 'hydrooj';
|
||||
import { moment, ObjectId } from 'hydrooj';
|
||||
|
||||
export { size, formatSeconds } from 'hydrooj';
|
||||
|
||||
@@ -10,10 +10,10 @@ export function ansiToHtml(str: string, whiteToBlack = true) {
|
||||
return whiteToBlack ? res.replace(/style="color:rgb\(255,255,255\)"/g, 'style="color:black"') : res;
|
||||
}
|
||||
|
||||
export function datetimeSpan(dt: Date | ObjectID, relative = true, format = 'YYYY-M-D H:mm:ss', tz = 'Asia/Shanghai') {
|
||||
export function datetimeSpan(dt: Date | ObjectId, relative = true, format = 'YYYY-M-D H:mm:ss', tz = 'Asia/Shanghai') {
|
||||
if (!dt) return 'DATETIME_SPAN_ERROR';
|
||||
if (dt instanceof ObjectID) dt = dt.getTimestamp();
|
||||
else if (typeof dt === 'string' && ObjectID.isValid(dt)) dt = new Date(new ObjectID(dt).generationTime * 1000);
|
||||
if (dt instanceof ObjectId) dt = dt.getTimestamp();
|
||||
else if (typeof dt === 'string' && ObjectId.isValid(dt)) dt = new ObjectId(dt).getTimestamp();
|
||||
else if (typeof dt === 'number' || typeof dt === 'string') dt = new Date(dt);
|
||||
return '<span class="time{0}" data-timestamp="{1}">{2}</span>'.format(
|
||||
relative ? ' relative' : '',
|
||||
|
||||
Reference in new issue
Block a user