scottstanfield/markdown-to-json

Narrow down date string parsing support

Closed this issue · 6 comments

As mentioned before, using moment to parse the date string broadened our date input support.

By default, YAML parsing (with js-yaml) will detect a few date string formats. That means js-yaml outputs Date objects from the frontmatter and that works as expected once we pass it into moment().

If js-yaml sees a non-standard date string (per YAML specifications) it will just output a string, which we then pass into moment(). Up until recently, they would try their best to parse it -- but now they (rightfully) decided to drop that (buggy) feature: moment/moment#1407

So I think we should narrow down the date string support and document it.
More specifically, we should support everything YAML supports by default, plus whatever moment supports by default without throwing deprecation warnings.

List of supported moment string formats: http://momentjs.com/docs/#/parsing/string/

Wait, there's no pull request yet!

Ok, will stand by for PR. I haven't touched the code in awhile. I'm going to force a small push to test travis.

So we can close this one out now @barraponto?

Yes :)