frictionlessdata / tableschema-rb

A Ruby library for working with JSON Table Schema.
MIT License
12 stars 10 forks source link

Use of Ruby Date.strptime(date_string, format) versus date_object.strftime(format) #42

Open jrjamespdx opened 5 years ago

jrjamespdx commented 5 years ago

Overview

Date format validation is currently not working as expected and definitely not working for ISO8601 validation. The issue seems to be that the lib/tableschema/types/date.rb cast_fmt method uses Date.strptime with flags from the iso8601 method, but Date.strptime does not support flags, but date_object.strftime does.

Links to docs: https://ruby-doc.org/stdlib-2.5.3/libdoc/date/rdoc/Date.html#method-c-strptime https://ruby-doc.org/stdlib-2.5.3/libdoc/date/rdoc/Date.html#method-i-strftime

I'll submit a PR for a change shortly.


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

roll commented 5 years ago

Thanks @jrjamespdx !