STDIO.LIB library bug report, "_atodt" giving strange results

The aforementioned function _atodt doesn’t seem to work well (DC 10.70 and 72) sometimes it returns partially random results.

In my opinion, it’s because the “t” structure is not initialized.

Line 2328:
auto struct tm t;

I changed it into:
auto struct tm t = {0, 0, 0};

With tm_sec, tm_min and tm_hour initialized to zero everything is working fine.

Hello , Can you explain what is the use of this function ?
Did you see this function details in any of the user’'s manual?

I have tested below code
struct tm t;
a=_atodt(“7/30/2013”);
printf("%d
",a);
printf( "Time: %s
", asctime( &t)); It returns 12266? I do not know what it is? can you explain?

Hello cpigilam, _atodt should return the days since 1/1/1980 given a “m/d/y” date: it is 12.264 days from “1/1/1980” to “7/30/2013”, so your result is incorrect as you can see

The function is not documented (afaik)

We are not aware of an issue with this function. Can you send a small workign sample that we can ereproduce your issue?

Hello MargaretK, unfortunately the issue is not easily reproducible. Afaik, if a struct that has “auto” storage is not initialized explicitly, its value is indeterminate. _atodt sets t.tm_mon, t.tm_mday and t.tm_year, but does not initialize t.tm_sec, t.tm_min and t.tm_hour before passing &t to mktime: that’s why the final result may be slightly different from what we expected (e.g. if t.tm_hour == 24 mktime will normalize tm_hour to zero and add 1 to tm_tm_day).

The function may give good results most of the times, but luckily for us cpigilam tried and got a wrong result (12266 instead of 12264, see comments above)