I´m retrieving file modification time using
type(FILE$INFO):: FileInfo integer(KIND=INT_PTR_KIND( ))Handle !... Handle=FILE$FIRST irc=GETFILEINFOQQ(trim(fname),FileInfo,Handle) if(irc.le.0)then ! ... endif call UNPACKTIMEQQ(FileInfo%lastwrite,iyr2,imon2,iday2,ihr2,imin2,isec2)
This yields a time of 19:44.
Windows explorer says it is 18:44.
GNU stat (on cygwin) says it is "2016-10-25 18:44:10.210373000 +0200"
My timezone is UTC+1, then we have daylight saving time, which sort of makes it UTC+2.
So it seems GetFileInfo/UnpackTimeQQ disregards DST - is this the expected behavior? Is there a fortran way to handle dst also? I´d like to avoid calling a C function, although I think I have a working solution there:
FILETIME modtime; LPFILETIME localModTime; SYSTEMTIME st; SYSTEMTIME stLocal; HANDLE fh; wchar_t path[256] = _T("my.file"); wchar_t date[80], time[80]; fh = CreateFileW(path, GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL); GetFileTime(fh, NULL, NULL, &modtime); FileTimeToSystemTime(&modtime, &st); SystemTimeToTzSpecificLocalTime(NULL, &st, &stLocal); int ret; ret = GetDateFormatEx(LOCALE_NAME_USER_DEFAULT, DATE_LONGDATE, &stLocal, NULL, date, sizeof date / sizeof date[0], NULL); ret = GetTimeFormatEx(LOCALE_NAME_USER_DEFAULT, 0, &stLocal, NULL, time, sizeof time / sizeof time[0]); wprintf(L"File last modified at %s at %s.\n", date, time);
Thanks!