Skip to content

Commit 2c778ca

Browse files
committed
Replace padStart implementation with slice to support node js 6
1 parent 7b763c9 commit 2c778ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/isISO8601.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const isValidDate = (str) => {
2525
const year = match[1];
2626
const month = match[2];
2727
const day = match[3];
28-
const monthString = month ? `${month}`.padStart(2, '0') : month;
29-
const dayString = day ? `${day}`.padStart(2, '0') : day;
30-
const yearString = year < 1000 ? `${year}`.padStart(4, '0') : year;
28+
const monthString = month ? `0${month}`.slice(-2) : month;
29+
const dayString = day ? `0${day}`.slice(-2) : day;
30+
const yearString = day ? `0000${year}`.slice(-4) : day;
3131

3232
// create a date object and compare
3333
const d = new Date(`${yearString}-${monthString || '01'}-${dayString || '01'}`);

0 commit comments

Comments
 (0)