ruby / csv

CSV Reading and Writing
https://ruby.github.io/csv/
BSD 2-Clause "Simplified" License
178 stars 113 forks source link

:date_time converter fails to recognize "YYYY-MM-DD HH:MM" #247

Closed thyresias closed 2 years ago

thyresias commented 2 years ago
require "csv"
csv = '2022-06-14 18:48'
p CSV.parse(csv, converters: :date_time).first.first #=> "2022-06-14 18:48"
p DateTime.parse(csv) #=> #<DateTime: 2022-06-14T18:48:00+00:00 ((2459745j,67680s,0n),+0s,2299161j)>

There are two ways to solve this, I'm not sure which is the best one:

kou commented 2 years ago

The former is the best because ISO 8601 requires T.

kou commented 2 years ago

Do you want to open a pull request for this?

thyresias commented 2 years ago

I can sure open a pull request, if you explain to me how this has to be done (or point me to a "how to"): I never did it before. ありがとう

kou commented 2 years ago

@ericgpks Could you support @thyresias ?

ericgpks commented 2 years ago

of course !

ericgpks commented 2 years ago

@thyresias Please fork this repository first of all, then create a branch to make a pull request. You make some changes on that branch and then push and open as a pull request. If you have any questions, you can ask anytime!!

thyresias commented 2 years ago

@ericgpks Thank you Eriko-san. I hope I did it right.