viant / toolbox

Toolbox - go utility library
Apache License 2.0
197 stars 29 forks source link

DateFormatToLayout does not work as expected #42

Closed JuroszBart closed 2 years ago

JuroszBart commented 2 years ago

Hi, I recently used this library for time parsing, and noticed strange error with DateFormatToLayout. It returns "2006-01-02 05:04:05" instead of "2006-01-02 15:04:05" which causes bug. Please check this code sample https://go.dev/play/p/uGKxa8vCsfH

adranwit commented 2 years ago

If you see error parsing: parsing time "2022-01-11 18:16:33": hour out of range0001-01-01 00:00:00 +0000 UTC 2022-01-11 18:16:33 +0000 UTC

The reason of the exception is that you have used lowercase 'hh' (0-12 hours only), vs HH that is 0-23