Merge pull request #1221 from cosmos/padded-implementation

Simplify padded implementation
This commit is contained in:
Simon Warta 2022-07-14 13:51:34 +02:00 committed by GitHub
commit b9bf5cc76c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,7 @@ const rfc3339Matcher =
/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(\.\d{1,9})?((?:[+-]\d{2}:\d{2})|Z)$/;
function padded(integer: number, length = 2): string {
const filled = "00000" + integer.toString();
return filled.substring(filled.length - length);
return integer.toString().padStart(length, "0");
}
export function fromRfc3339(str: string): Date {