TM, Time_t,systemtime conversion

Source: Internet
Author: User

time_t tmtotime_t (char * DT)

{

TM Timeinfo;
sscanf_s (DT, "%d-%d-%d%d:%d:%d",
&timeinfo.tm_year, &timeinfo.tm_mon, &timeinfo.tm_mday,
&timeinfo.tm_hour, &timeinfo.tm_min, &timeinfo.tm_sec);
Timeinfo.tm_year-= 1900;
Timeinfo.tm_mon-= 1; Month:0-11
Return Mktime (&timeinfo);

}

time_t systemtimetotime_t (const systemtime& ST) {
TM Temptm = {st.wsecond,
St.wminute,
St.whour, St.wday,
St.wmonth-1,
st.wyear-1900,
St.wdayofweek,
0,
0};
return Mktime (&TEMPTM);
}


SYSTEMTIME timettosystemtime (time_t t)
{
filetime ft;
SYSTEMTIME PST;
//longlong NLL = int32x32to64 (t, 10000000) + 116444736000000000   Time difference 8 hours
Longlong NLL = int32x32to64 (T, 10 000000) + 116445024000000000;


Ft.dwlowdatetime = (DWORD) NLL;
Ft.dwhighdatetime = (DWORD) (NLL >> 32);
FileTimeToSystemTime (&ft, &pst);
return PST;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.