grate icon indicating copy to clipboard operation
grate copied to clipboard

Fixed formatting of time strings without seconds

Open mbgonicus opened this issue 1 year ago • 0 comments

When creating a formatter with the format "hh:mm", then makeFormatters will not detect the "mm" as minutes, but as months, and will therefore create an incorrect output. For example, the 22nd November at the time 13:37 will produce "13:11" instead of "13:37", as expected.

This commit adds a unit test for the errornous case and a fix for the regular expression that detects a time string. Now, seconds are optional.

It is probably a good idea to rethink the regex, as it might produce more errors.

mbgonicus avatar Nov 22 '23 14:11 mbgonicus