From 4e3d2269173a4ea90186e1076d01cfe7d0ea70c4 Mon Sep 17 00:00:00 2001 From: Menci Date: Fri, 17 Mar 2017 23:21:22 +0800 Subject: [PATCH] Allow < 0 time in contest ranklist --- utility.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utility.js b/utility.js index 6767fc9..a56729d 100644 --- a/utility.js +++ b/utility.js @@ -96,12 +96,14 @@ module.exports = { return m.format(format || 'L H:mm:ss'); }, formatTime(x) { + let sgn = x < 0 ? '?' : ''; + x = Math.abs(x); function toStringWithPad(x) { x = parseInt(x); if (x < 10) return '0' + x.toString(); else return x.toString(); } - return util.format('%s:%s:%s', toStringWithPad(x / 3600), toStringWithPad(x / 60 % 60), toStringWithPad(x % 60)); + return sgn + util.format('%s:%s:%s', toStringWithPad(x / 3600), toStringWithPad(x / 60 % 60), toStringWithPad(x % 60)); }, formatSize(x) { let res = filesize(x, { fixed: 1 }).calculate();