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" <mauc...@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@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest