DEvil0000
DateTime.from_iso8601 can not read basic format produced by DateTime.to_iso8601
I get some DateTime strings I wanted to parse.
DateTime looks quite nice for such things but somehow it can produce the datetime strings in the exact same format but it can not parse them.
I was expecting it can at least parse what it can produce
datetime = DateTime.utc_now
datetime_basic_string = DateTime.to_iso8601(datetime, :basic)
DateTime.from_iso8601(datetime_basic_string)
#sadly results in {:error, :invalid_format}
Most Liked
Ankhers
Like the documentation for DateTime.from_iso8601/2 says (emphasis mine),
Parses the extended “Date and time of day” format described by ISO 8601:2004.
It currently does not even try to parse the “basic” version.
DEvil0000
I do not say the documentation does not match the behaviour. I say the behaviour is unexpected and does not make sense.
If it can produce it parsing should also be possible.
Its a missing feature if you want it that way
grych
True, it would be more consistent if it would work both ways (:basic and :extended).
Well, you should do the PR then. As your change makes sense and does not harm the existing API, should be accepted!







