Speedup date code (msToGregorianDateTime) by only handling positive values msToGregorianDateTime and the associated static inline support functions are slow due to needing to handle negative values for ms. Instead we should detect that ms is negative, flip the sign, send it through normal processing and then flip the signs on the resulting GregorianDateTime. This would add a branch, but would greatly speed up date processing due to the removal of all of the floor() calls.
flipping the sign would not in itself allow us to remove calls to floor. Our date math has changed a lot in the last 4 years, I don't think this bug is still tracking active optimization effort.