Skip to content

Commit

Permalink
Replace padStart implementation with slice to support node js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
skpanagiotis committed Jan 19, 2025
1 parent 7b763c9 commit 2c778ca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/isISO8601.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const isValidDate = (str) => {
const year = match[1];
const month = match[2];
const day = match[3];
const monthString = month ? `${month}`.padStart(2, '0') : month;
const dayString = day ? `${day}`.padStart(2, '0') : day;
const yearString = year < 1000 ? `${year}`.padStart(4, '0') : year;
const monthString = month ? `0${month}`.slice(-2) : month;
const dayString = day ? `0${day}`.slice(-2) : day;
const yearString = day ? `0000${year}`.slice(-4) : day;

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

0 comments on commit 2c778ca

Please sign in to comment.