feat(CountDown): support SS and S format (#5154)

This commit is contained in:
neverland
2019-11-30 08:58:36 +08:00
committed by GitHub
parent d1a8adab20
commit 7f2e9b21c3
6 changed files with 70 additions and 6 deletions

View File

@@ -57,7 +57,19 @@ export function parseFormat(format: string, timeData: TimeData): string {
format = format.replace('ss', padZero(seconds));
}
return format.replace('SSS', padZero(milliseconds, 3));
if (format.indexOf('S') !== -1) {
const ms = padZero(milliseconds, 3);
if (format.indexOf('SSS') !== -1) {
format = format.replace('SSS', ms);
} else if (format.indexOf('SS') !== -1) {
format = format.replace('SS', ms.slice(0, 2));
} else {
format = format.replace('S', ms.charAt(0));
}
}
return format;
}
export function isSameSecond(time1: number, time2: number): boolean {