core: fix contest_edit timezone convert

This commit is contained in:
undefined committed 2022-10-24 02:57:12 +08:00
1 parent 0c587d1786
commit c00c2160ec
7 files changed
+22 -23

No files matched your search

+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "4.2.8",
"version": "4.2.9",
"bin": "bin/hydrooj.js",
"main": "src/plugin-api",
"module": "src/plugin-api",
@@ -12,11 +12,11 @@
},
"preferUnplugged": true,
"dependencies": {
"@aws-sdk/client-s3": "^3.186.0",
"@aws-sdk/lib-storage": "^3.186.0",
"@aws-sdk/middleware-endpoint": "^3.186.0",
"@aws-sdk/s3-presigned-post": "^3.186.0",
"@aws-sdk/s3-request-presigner": "^3.186.0",
"@aws-sdk/client-s3": "^3.194.0",
"@aws-sdk/lib-storage": "^3.194.0",
"@aws-sdk/middleware-endpoint": "^3.193.0",
"@aws-sdk/s3-presigned-post": "^3.194.0",
"@aws-sdk/s3-request-presigner": "^3.194.0",
"@graphql-tools/schema": "^8.5.1",
"@hydrooj/utils": "workspace:*",
"adm-zip": "0.5.5",
@@ -39,7 +39,7 @@
"lodash": "^4.17.21",
"lru-cache": "7.12.0",
"mime-types": "^2.1.35",
"moment-timezone": "^0.5.37",
"moment-timezone": "^0.5.38",
"mongodb": "^3.7.3",
"nanoid": "^4.0.0",
"nodemailer": "^6.8.0",
+3 -2
View File
@@ -293,12 +293,13 @@ export class ContestEditHandler extends Handler {
}
let ts = Date.now();
ts = ts - (ts % (15 * Time.minute)) + 15 * Time.minute;
const beginAt = moment(this.tdoc?.beginAt || new Date(ts)).tz(this.user.timeZone);
this.response.body = {
rules,
tdoc: this.tdoc,
duration: tid ? (this.tdoc.endAt.getTime() - this.tdoc.beginAt.getTime()) / Time.hour : 2,
duration: tid ? -beginAt.diff(this.tdoc.endAt, 'hour', true) : 2,
pids: tid ? this.tdoc.pids.join(',') : '',
beginAt: this.tdoc?.beginAt || new Date(ts),
beginAt,
page_name: tid ? 'contest_edit' : 'contest_create',
};
}