frictionlessdata / tableschema-js

A JavaScript library for working with Table Schema.
http://frictionlessdata.io/
MIT License
82 stars 27 forks source link

Check for leap years or short months when giving a custom date format #159

Closed UnicodingUnicorn closed 4 years ago

UnicodingUnicorn commented 4 years ago

This is technically a continuation of #114. Pull request #158 resolves this when using 'default' but does not change the behaviour of custom specified formats.

The problem lies with the format parser, d3-time-format, passes dates directly to a JavaScript Date object which glosses over such things. The pull request solves it by directly parsing the supplied date with moment.js, which does perform such error checking.

Since the format strings of d3-time-format do not have a one-to-one mapping to the format strings of moment.js, solving this issue is not a simple method of putting in a regex replace. The format strings are also required by the spec.

I believe that either the issue needs a fix from the upstream dependency (i.e. d3/d3-time-format#47), or for tableschema-js to switch to a different dependency. I'm opening this issue as more of a documentation thing.


Please preserve this line to notify @roll (lead of this repository)

roll commented 4 years ago

@UnicodingUnicorn Thanks for creating the issue!

For now, we only can consider it as a limitation of underlying libraries.