https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77760
Bug ID: 77760
Summary: get_time needs to set tm_wday amd tm_yday
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: drepper.fsp+rhbz at gmail dot com
Target Milestone: ---
Created attachment 39701
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39701&action=edit
Test case to show get_time vs strptime
Currently the get_time function sets the tm_wday member of tm only when
explicitly asked and doesn't set tm_yday at all. This does not match
strptime() which this function should emulate.
Basically, every time the parsing has enough information to compute that data
it should be done. In the simplest case, of day of the month, month, and year
are known the two fields can be computed.
The glibc strptime function does all that. It gets complicated, true, but
users of the functions will expect this behaviour since otherwise the results
are strange. I know the standard does not explicitly say this. See the
attached code for a test case. I see
Sun Sep 27 03:11:41 2016 vs Tue Sep 27 03:11:41 2016 FAIL
because tm_wday == 0 means Sunday.