Fix incorrectly handled time values around 12:00:00

When using 12 hour formats & intervals, values around 12:00 were
incorrecly converted to midnight.

Fixes #2507