XC32 mktime() 問題

作者 jasondte 於 2015年07月20日 16:22:21
使用 mktime 發現結果總是不對, rt1 = 1382976320, 正確應該是 1382932800.(2013年10月28日12:00:00)
當執行過 rt1 = mktime(&st1); 這一行後
st1.tm_sec = 0; --> 變為 20
st1.tm_min = 0; --> 變為 5
st1.tm_hour = 12;--> 變為 13

執行過 at1 = gmtime(&rt1);
at1->tm_sec = 20;
at1->tm_min = 5;
at1->tm_hour = 16;
at1->tm_mday = 28;
at1->tm_mon = 9;
at1->tm_year = 113;
at1->tm_wday = 1;
at1->tm_yday = 300;
at1->tm_isdst = 0;

請問問題何在?

time_t RTCTime(void)
{
struct tm st1;
struct tm *at1;
time_t rt1, rt2;

st1.tm_sec = 0;
st1.tm_min = 0;
st1.tm_hour = 12;
st1.tm_mday = 28;
st1.tm_mon = 9;
st1.tm_year = 2013-1900;
st1.tm_wday = 0;
st1.tm_yday = 0;
st1.tm_isdst = -1;

rt1 = mktime(&st1);
//t2 = (time_t)1382932800;
at1 = gmtime(&rt1);

return(rt1);
}

來自: http://www.microchip.com.tw/newbb/viewtopic.php?forum=8&topic_id=17613&post_id=67747