Skip to content

Commit

Permalink
Merge pull request #1 from immuta/fix/support-moment-2.25
Browse files Browse the repository at this point in the history
Add support for moment >= 2.25
  • Loading branch information
jeffmhastings authored May 11, 2022
2 parents 85c5913 + 939f9f4 commit d22d61e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit d22d61e

Please sign in to comment.