Simplify padded implementation

This commit is contained in:
Simon Warta 2022-07-14 13:29:59 +02:00
parent 70e0549ed7
commit 64ee51db5b

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 {