Fix potential undefined behaviour in corner cases of floating-point-to-time conversions.