Open anthonylouisbsb opened 3 years ago
This looks like a bug in date.h. I should set failbit
if %I
is used without %p
. Otherwise 10:01:01
is ambiguous. Is that AM or PM?
I've just pushed a fix for this to master.
@HowardHinnant To keep a similar behavior with the native strptime function, I think the %I
flag should consider as AM If the user does not define a value for the %p
flag.
Thanks for the link to the linux docs. I looked there, and at the posix strptime spec. In neither place am I seeing a default for am/pm. Maybe I'm just missing it. Could you point to the part of the spec that says this? Thanks.
@HowardHinnant I did not find anything in specs too, I was based on an empirical test using the gcc
compiler in the Apache Arrow project.
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
But I think your suggestion is right, if the user not define if it is AM
or PM
is ambiguous to know how to parse the date.
If I find something that says how the POSIX specs define the behavior for that case, I will share it here.
Thanks for the quick response and for correcting the problem!
@HowardHinnant I added a Pull Request with some unit tests related to the change you made.
I have a problem to parse dates using the
%I
format option to timestamps. Check the following code:When I display the output variable
out
, considering that theignore_time_in_day
variable isfalse
and theresponse_unit
variable is different fromSECOND
, the result is533779261000
that corresponds to the1986-12-01 00:01:01
datetime, not the datetime defined by the user.If I change the
%I
formatter option to the 24h clock option%H
, the method works fine.I am doing something wrong in my code or there is a bug with the format option for 12h clocks?