diff --git a/README.md b/README.md index 9707b2e..6d6fdf7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A [Waterline](https://github.com/waterlinejs) adapter for ## Compatibility - [Waterline](http://waterline.js.org) v0.10 and newer - [Trails](http://trailsjs.io) v1.0 and newer -- Node 4 or newer +- Node 12 or newer ## Install diff --git a/lib/util.js b/lib/util.js index 6615428..528a463 100644 --- a/lib/util.js +++ b/lib/util.js @@ -191,7 +191,10 @@ const Util = { } if (_.isString(value)) { let stripped = value.replace(/\"/g, '') - if (moment(stripped, moment.ISO_8601, true).isValid()) { + // 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 + // 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()) { return new Date(stripped).valueOf() } }