Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » DST issue in Time()
DST issue in Time() [message #49666] Tue, 27 March 2018 09:08 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
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


Best regards
IƱaki
 
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: Fri Apr 19 18:22:06 CEST 2024

Total time taken to generate the page: 0.04213 seconds