U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » DST issue in Time()
Re: DST issue in Time() [message #49667 is a reply to message #49666] Tue, 27 March 2018 15:49 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 27 March 2018 09:08
Hello all

Please check if we handle Daylight saving time properly in Windows.

I have checked it in C: local NTFS disk from Windows 10 and actual code does not report right hour.
However, from a Linux virtual machine, same code report properly the file time Smile

Actual code for Windows:
Time::Time(FileTime filetime) {
	SYSTEMTIME tm;
	FileTime ft;
	FileTimeToLocalFileTime(&filetime, &ft);
	FileTimeToSystemTime(&ft, &tm);
	*this = Time(tm.wYear, tm.wMonth, tm.wDay, tm.wHour, tm.wMinute, tm.wSecond);
}

Proposed code:
Time::Time(FileTime filetime) {
	SYSTEMTIME tm, tml;
	FileTimeToSystemTime(&filetime, &tm);
	SystemTimeToTzSpecificLocalTime(NULL, &tm, &tml);

	*this = Time(tml.wYear, tml.wMonth, tml.wDay, tml.wHour, tml.wMinute, tml.wSecond);
}

See this:
To account for daylight saving time when converting a file time to a local time, use the following sequence of functions in place of using FileTimeToLocalFileTime:

    FileTimeToSystemTime
    SystemTimeToTzSpecificLocalTime


Can you give me some context? E.g. testcase?

So far, I have tried with FileSel and time is reported correctly (for file that I have just saved and I have DST active here).

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Curious problem wth Vector
Next Topic: [BUG #1854] SegFault when calling CParser::NoSkipComments() before term initialisation
Goto Forum:
  


Current Time: Sat Sep 19 22:17:14 GMT+2 2026

Total time taken to generate the page: 0.03307 seconds