mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
ui: add contest_timer
This commit is contained in:
1 parent
72c3e48f1b
commit
dffca5f8c7
4 files changed
+37
-18
No files matched your search
@@ -149,6 +149,20 @@ export function parseMemoryMB(str: string | number, throwOnError = true) {
|
||||
return Math.ceil(parseFloat(match[1]) * MEMORY_UNITS[match[2].toLowerCase()]);
|
||||
}
|
||||
|
||||
function _digit2(number: number) {
|
||||
return number < 10 ? `0${number}` : number.toString();
|
||||
}
|
||||
|
||||
export function formatSeconds(_seconds: string | number = '0', showSeconds = true) {
|
||||
const seconds = +_seconds;
|
||||
let res = '{0}:{1}'.format(
|
||||
showSeconds ? _digit2(Math.floor(seconds / 3600)) : Math.floor(seconds / 3600),
|
||||
_digit2(Math.floor((seconds % 3600) / 60)),
|
||||
);
|
||||
if (showSeconds) res += `:${_digit2(seconds % 60)}`;
|
||||
return res;
|
||||
}
|
||||
|
||||
export function size(s: number, base = 1) {
|
||||
s *= base;
|
||||
const unit = 1024;
|
||||
|
||||
@@ -190,20 +190,6 @@ export function errorMessage(err: Error | string) {
|
||||
return err;
|
||||
}
|
||||
|
||||
function _digit2(number: number) {
|
||||
return number < 10 ? `0${number}` : number.toString();
|
||||
}
|
||||
|
||||
export function formatSeconds(_seconds: string | number = '0', showSeconds = true) {
|
||||
const seconds = +_seconds;
|
||||
let res = '{0}:{1}'.format(
|
||||
showSeconds ? _digit2(Math.floor(seconds / 3600)) : Math.floor(seconds / 3600),
|
||||
_digit2(Math.floor((seconds % 3600) / 60)),
|
||||
);
|
||||
if (showSeconds) res += `:${_digit2(seconds % 60)}`;
|
||||
return res;
|
||||
}
|
||||
|
||||
export function changeErrorType(err: any, Err: any) {
|
||||
const e = new Err(err.message);
|
||||
e.stack = err.stack;
|
||||
|
||||
Reference in new issue
Block a user