diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge.java index a7ee4ce4..b7dc6c5d 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge.java @@ -143,7 +143,7 @@ public class CodeForcesJudge implements RemoteJudgeStrategy { .put("status", statusType.getStatus()).build(); } resultMap.put("time", result.get("timeConsumedMillis")); - resultMap.put("memory", result.get("memoryConsumedBytes")); + resultMap.put("memory", (int) result.get("memoryConsumedBytes") / 1024); Constants.Judge resultStatus = statusMap.get(verdict); if (resultStatus == Constants.Judge.STATUS_COMPILE_ERROR) { diff --git a/hoj-vue/src/common/time.js b/hoj-vue/src/common/time.js index 511fc54b..0c527e60 100644 --- a/hoj-vue/src/common/time.js +++ b/hoj-vue/src/common/time.js @@ -17,6 +17,40 @@ function duration (startTime, endTime) { return duration.humanize() } +function formatSpecificDuration(startTime, endTime){ + let start = moment(startTime) + let end = moment(endTime) + let ms = moment.duration(start.diff(end, 'seconds'), 'seconds') + if (ms < 0) ms = -ms; + let arr=[86400000,3600000,60000,1000]; + let en_time=['day','hour','minute','second']; + let zh_time=['天','小时','分','秒']; + + let res = ''; + + if(i18n.locale=='en-US'){ + for(let i=0;i=1){ + res+=tmp+' '+en_time[i]; + if(tmp!=1){ + res+='s'; + } + return res; + } + } + }else if(i18n.locale=='zh-CN'){ + + for(let i=0;i=1){ + return tmp+zh_time[i]; + } + } + } +}; + + function formatDuration(time){ let duration = moment.duration(time) return duration.humanize() @@ -38,6 +72,7 @@ function durationMs (startTime, endTime) { // 计算时间段的时间戳 export default { utcToLocal: utcToLocal, duration: duration, + formatSpecificDuration:formatSpecificDuration, secondFormat: secondFormat, durationMs:durationMs, formatDuration:formatDuration diff --git a/hoj-vue/src/views/oj/Home.vue b/hoj-vue/src/views/oj/Home.vue index 7a8903c2..68e8c515 100644 --- a/hoj-vue/src/views/oj/Home.vue +++ b/hoj-vue/src/views/oj/Home.vue @@ -312,7 +312,7 @@ export default { }); }, getDuration(startTime, endTime) { - return time.duration(startTime, endTime); + return time.formatSpecificDuration(startTime, endTime); }, getRankTagClass(rowIndex) { return 'rank-tag no' + (rowIndex + 1); diff --git a/hoj-vue/src/views/oj/contest/ContestList.vue b/hoj-vue/src/views/oj/contest/ContestList.vue index e4f9feec..f1015388 100644 --- a/hoj-vue/src/views/oj/contest/ContestList.vue +++ b/hoj-vue/src/views/oj/contest/ContestList.vue @@ -287,7 +287,7 @@ export default { } }, getDuration(startTime, endTime) { - return time.duration(startTime, endTime); + return time.formatSpecificDuration(startTime, endTime); }, getborderColor(contest) { return (