SYSTEMTIME, Fileitime, Locltime, UTC, Qdatetime and many other times

Source: Internet
Author: User
Tags filetime

1.UTC: World Coordination Time

2.LOcalTime: local time, which is the current time of the system setting time zone;

3.SYSTEMTIME: GMT, minus time zone by local time, and localtime are stored with SYSTEMTIME structure;

4.FileTime: Based on UTC, is a value of a single bit, recording the number of seconds from 1609-01-01 00:00:00 to now, accurate to nanosecond;

5.time_t Timestamp: The value of a single bit, recording the number of seconds from 1970-01-01 00:00:00 to the present;

6.QDateTime is a combination of qdate and Qtime in Qt, providing a range of processing functions.

Several functions are used:

1. FILETIME converted to Systemtime:bool filetimetosystemtime (const FILETIME *lpfiletime, Lpsystemtime lpsystemtime);

FILETIME FILETIME;

SYSTEMTIME Systime;

FileTimeToSystemTime (&filetime, &systime);

Note: Two & must add, the first is to take the address, the second temporarily do not know why, but will not be reported can not be converted from systemtime to Lpsystemtime;

2.FILETIME converted into time_t, using intermediate variables Ularge_integer

FILETIME FILETIME;

Ularge_integer ull;
Ull. LowPart =filetime.dwlowdatetime;
Ull. Highpart = Filetime.dwhighdatetime;
time_t time_create= ull. Quadpart/10000000ull-11644473600ull;

3.SYSTEME is converted into string form, because there is no direct conversion function, can be converted to string form by Qdatetime;filetime, first converted to Systeme.

SYSTEMTIME Dircreatetime;
FILETIME FILETIME;
Expect_true (FileTimeToSystemTime (&filetime,&dircreatetime));
Qdatetime Qdatetime;
Qdatetime.setdate (Qdate (Dircreatetime.wyear, Dircreatetime.wmonth, Dircreatetime.wday));
Qdatetime.settime (Qtime (Dircreatetime.whour, Dircreatetime.wminute, Dircreatetime.wsecond));
QString format = "Yyyy-mm-dd hh:mm:ss";
QString str_time=qdatetime.tostring (format);

SYSTEMTIME, Fileitime, Locltime, UTC, Qdatetime and many other times

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.