G
Guest
Hi There,
I just found that there is a problem in vc2005 regarding to time_t and
localtime. See code snippets belows. Using this code segment, I found that
when ut is 86200, the corresponding output is 1970.1.1 7:56:40, when ut is 0,
the output is 1970.1.1 8:00:00, when ut is 86400, the output is 1970.1.2
8:00:00. While output will be 1970 1.2 7:56:40 in VC8. Please note that I
am aware that time_t is 64bit in VC2005 and using _USE_32BIT_TIME_T can force
time_t behave like 32bit, but don't plan to use this workaround.
time_t ut;
ut = (time_t) 86200;
struct tm tm = *localtime(&ut);
cout << tm.tm_year << endl;
cout << tm.tm_mon << endl;
cout << tm.tm_mday << endl;
cout << tm.tm_hour << endl;
cout << tm.tm_min << endl;
cout << tm.tm_sec << endl;
Any comments/thoughts/suggestions is highly appreciated.
Thanks,
-Yuanfei
I just found that there is a problem in vc2005 regarding to time_t and
localtime. See code snippets belows. Using this code segment, I found that
when ut is 86200, the corresponding output is 1970.1.1 7:56:40, when ut is 0,
the output is 1970.1.1 8:00:00, when ut is 86400, the output is 1970.1.2
8:00:00. While output will be 1970 1.2 7:56:40 in VC8. Please note that I
am aware that time_t is 64bit in VC2005 and using _USE_32BIT_TIME_T can force
time_t behave like 32bit, but don't plan to use this workaround.
time_t ut;
ut = (time_t) 86200;
struct tm tm = *localtime(&ut);
cout << tm.tm_year << endl;
cout << tm.tm_mon << endl;
cout << tm.tm_mday << endl;
cout << tm.tm_hour << endl;
cout << tm.tm_min << endl;
cout << tm.tm_sec << endl;
Any comments/thoughts/suggestions is highly appreciated.
Thanks,
-Yuanfei