Skip to content

Commit

Permalink
Merge pull request #2 from immuta/fix/moment-yyyymm
Browse files Browse the repository at this point in the history
increase ignored date string length to 6 for yyyymm
  • Loading branch information
jeffmhastings authored May 26, 2022
2 parents d22d61e + 8418763 commit e639530
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ const Util = {
}
if (_.isString(value)) {
let stripped = value.replace(/\"/g, '')
// Check the length of the stripped string. If it's longer than 4 characters, then convert it to a date using moment.
// This is to prevent an incompatibility with newer versions of moment that treat all 4 digit strings as years, which
// Check the length of the stripped string. If it's longer than 6 characters, then convert it to a date using moment.
// This is to prevent an incompatibility with newer versions of moment that treat all 4-6 digit strings as years, which
// is technically in the ISO_8601 spec, but is not consistent with the way this library uses moment to parse dates.
if (stripped.length > 4 && moment(stripped, moment.ISO_8601, true).isValid()) {
if (stripped.length > 6 && moment(stripped, moment.ISO_8601, true).isValid()) {
return new Date(stripped).valueOf()
}
}
Expand Down

0 comments on commit e639530

Please sign in to comment.