jackc / tod

Time of day and shift types for Ruby
MIT License
435 stars 56 forks source link

Update parsing regexes to handle (ignore) milliseconds #82

Closed efatsi closed 3 years ago

efatsi commented 3 years ago

This is a potential fix to the issue brought up in #75.

Rails outputs times in the following format: "04:30:00.000", which TimeOfDay can't parse (returning nil if you try to set a tod field to that value).

This PR updates the regex to optionally match on the .000 (and do nothing with it). It uses a non-capturing group in order to not disturb the existing order of regex matches.

jackc commented 3 years ago

LGTM. Thanks!