-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Not necessarily an issue with Tod, but a small change to Tod would fix the problem.
Using Tod::TimeOfDay in a Rails 5 app, with Chrome and HTML time fields. There seems to be an odd bit of behaviour in Chrome, in that if an HTML time field has been modified by the user, the contents are returned as "08:30", whilst if the field remains unmodified from when the form was created, the same field comes back as "08:30:00.000", which Tod::TimeOfDay.parse doesn't understand, resulting in the field in the database record being set to nil.
It would appear that when you create a time field in Rails for an item held in a Tod::TimeOfDay with:
<%= f.time_field :my_tod_time %>
Then the format used in the HTML sent to the browser is "08:30:00.000", and if the user doesn't modify it then that's what Chrome sends back. Tod::TimeOfDay then doesn't understand it and you end up with a nil field. I've tried changing default formatting for both Time and Tod::TimeOfDay but neither has en effect. I've yet to identify what causes the long string to be generated in the first place.
I'm far from sure where the fundamental inconsistency is here. Feedback appreciated.