diff --git a/packages/metascraper-helpers/index.js b/packages/metascraper-helpers/index.js index 010ece9578..699e283f8a 100644 --- a/packages/metascraper-helpers/index.js +++ b/packages/metascraper-helpers/index.js @@ -198,10 +198,6 @@ const date = value => { // convert isodates to restringify, because sometimes they are truncated if (isIso(value)) return new Date(value).toISOString() - // try to parse with the built-in date parser - const native = new Date(value) - if (!isNaN(native.getTime())) return native.toISOString() - // try to parse a complex date string const parsed = chrono.parseDate(value) if (parsed) return parsed.toISOString() diff --git a/packages/metascraper-helpers/test/index.js b/packages/metascraper-helpers/test/index.js index 6b17500a19..fea976e4da 100644 --- a/packages/metascraper-helpers/test/index.js +++ b/packages/metascraper-helpers/test/index.js @@ -19,7 +19,8 @@ const { url, jsonld, titleize, - hasValue + has, + date } = require('..') describe('metascraper-helpers', () => { @@ -266,6 +267,11 @@ describe('metascraper-helpers', () => { ).be.equal('Wikipedia: #Edit2014') }) }) + it('.date', () => { + should(date('Jun 20')).be.equal('2019-06-20T12:00:00.000Z') + should(date('Jun 20 2018')).be.equal('2018-06-20T12:00:00.000Z') + should(date('Jun 2018')).be.equal('2018-06-01T12:00:00.000Z') + }) }) describe('.hasValue', () => {