[Interest] Relashionship between time_t and QDateTime

Constantin Makshin cmakshin at gmail.com
Mon Aug 26 19:32:29 CEST 2013


As far as I understand the description of QDateTime::fromTime_t(), it
automatically converts the passed value from UTC to local time. On the
other hand, QFileInfo::lastModified() may immediately return the value
retrieved from the system without any transformations.
On Aug 26, 2013 7:43 PM, "Calogero Mauceri" <mauceri at actgate.com> wrote:

>  Hi all,
>
> I'm facing the following problem when initializing a QDateTime with time_t
> value.
> I get the last modified timestamp of a file as time_t value
>
>         ...
>     time_t mtime;
>     struct stat statbuf;
>     fstat(fd, &statbuf);
>     mtime = statbuf.st_mtime;
>     ...
>
> Then I use that mtime value to initialize a QDateTime as follows:
>
>     QDateTime myDateTime = QDateTime::fromTime_t(f_mtime);
>
> The date time printed doing a myDateTime.toString() is
>
>      Wed Dec 5 12:36:18 2007
>
>
> Retrieving the last modified information using QFileInfo, the result is
> different
>
>     QFileInfo fi(filepath);
>     QDateTime myDateTime = fi.lastModified();
>
> I get this result
>
>     Wed Dec 5 11:36:18 2007
>
> That is there is one hour difference. I guess the difference is due to the
> daylight saving management,
> but I can not understand how that management is performed.
>
> Note: if I look at the file properties on Windows dialog, the last
> modified time is shown as
>
>     Wed Dec 5 12:36:18 2007
>
>
>
> Thanks in advance for your help.
>     Calogero
>
> --
> Calogero Mauceri
> Software Engineer
>
> Applied Coherent Technology Corporation (ACT)www.actgate.com
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130826/8b61cc42/attachment.html>


More information about the Interest mailing list