erlware / erlware_commons

Erlware Commons is an Erlware project focused on all aspects of reusable Erlang components.
http://erlware.github.io/erlware_commons/
MIT License
219 stars 101 forks source link

fixed incorrect 'G' in the format parameter string #160

Closed CuteReimu closed 3 years ago

CuteReimu commented 3 years ago

In the format parameter string, 'G' should have represented 24-hour format of an hour WITHOUT leading zeros. But it actually results in 24-hour format of an hour WITH leading zeros.

ferd commented 3 years ago

This seems to cause a lot of test failures. Do they need an update to match the bug?

CuteReimu commented 3 years ago

The macro ISO_8601_DATETIME_FORMAT is incorrect. It should be "Y-m-dTH:i:sZ" rather than "Y-m-dTG:i:sZ". So is ISO_8601_DATETIME_WITH_MS_FORMAT. That will fix the test failures.

ferd commented 3 years ago

Can you add a single test that at least shows the desired padding behaviour of G ? Something like this:

https://github.com/erlware/erlware_commons/blob/ad559ae1f5f4cabdcc59899e20f4d3db78177574/src/ec_date.erl#L764

so something like this:

?_assertEqual(format("D M j G:i:s Y", {{2001,3,10},{5,16,17}}), "Sat Mar 10 05:16:17 2001"),
?_assertEqual(format("D M j H:i:s Y", {{2001,3,10},{5,16,17}}), "Sat Mar 10 5:16:17 2001"),

on the line below, since we apparently never tested the padding behaviour.

CuteReimu commented 3 years ago

Ok, I'll add some test cases to show the difference between 'H' and 'G'.