Page 1 of 1
Show file time independent of daylight saving setting
Posted: 2011-03-10, 09:36 UTC
by tcdailyuser
When the system time changes from daylight saving time to standard time, the file times change by 1 hour

. Microsoft describes in
MSDN how to detect the real time (independent of the current settings of daylight saving time):
FileTimeToLocalFileTime uses the current settings for the time zone and daylight saving time. Therefore, if it is daylight saving time, this function will take daylight saving time into account, even if the time you are converting is in standard time. You can use the following sequence of functions as an alternative.
1.FileTimeToSystemTime
2.SystemTimeToTzSpecificLocalTime
3.SystemTimeToFileTime
I tried this in a private project and it seems to work fine. So I suggest to use this proceeding in Total Commander. I guess the option "1hourdif" then will not be needed in many cases.
Posted: 2011-03-10, 15:58 UTC
by ghisler(Author)
Unfortunately you will still get different results when the file is on a FAT32 drive than when it's on an NTFS drive. I guess that different functions need to be used depending on what file system the file is on. But even then there will be differences when the file was copied from one drive type to the other with Explorer or Total Commander.
Re: Show file time independent of daylight saving setting
Posted: 2011-03-10, 19:54 UTC
by fenix_productions
2
tcdailyuser
tcdailyuser wrote:
I tried this in a private project and it seems to work fine.
Would it be possible for you to write WDX plugin for that? Content plugins API is rather simple and it seems to me that you've got the most important part of the code already

Posted: 2011-03-11, 09:12 UTC
by tcdailyuser
ghisler(Author) wrote:Unfortunately you will still get different results when the file is on a FAT32 drive than when it's on an NTFS drive. I guess that different functions need to be used depending on what file system the file is on. But even then there will be differences when the file was copied from one drive type to the other with Explorer or Total Commander.
I did a little test using my suggested algorithm: You are right, there are differences between file systems.
My results (the FAT32-Files have been copied from NTFS):
- - On NTFS the algorithm works fine.
- On FAT32 the algorithm works fine, when the system is in standard time.
- FAT32: When the system is in daylight saving time, the file time of ALL files have a difference of 1 hour.
This makes my suggestion a little bit more complicated, but (I guess) it is possible to solve it. And it would be good when Total Commander displays exact values (another advantage over Windows Explorer).
Using current version of Total Commander, the displayed file times are equal (NTFS and FAT32) when the system is in standard time. In daylight saving time all file times differ by 1 hour. In all cases the time of some files is wrong:
- - NTFS: Those files which were changed in daylight saving time (now we have standard time) are displayed wrong (difference of 1 hour).
- NTFS: In summer the file times of files which where changed in winter will be wrong.
- FAT32: same behaviour like NTFS in standard time
Posted: 2011-03-14, 15:18 UTC
by ghisler(Author)
The real problems occur when you copy a file in Explorer or TC during standard time, and then the time switches to daylight saving time, or vice versa.
Posted: 2011-03-15, 07:56 UTC
by tcdailyuser
What does "The real problems occur" mean? A difference of one hour? This problem we have in the current Total Commander version too.
(But you are right, this problem won't be solved with my suggestion when copying files from NTFS to FAT or vice versa.

)
So only two advantages of my suggestion remain:
- displayed file times would not change when the system switches from standard to daylight saving time (or vice versa)
- the displayed file times on NTFS would be correct (at least if the file was not copied from FAT)
Posted: 2011-03-17, 15:16 UTC
by ghisler(Author)
But you are right, this problem won't be solved with my suggestion when copying files from NTFS to FAT or vice versa.
Exactly. You get the same time in some cases with my solution (which is the same as in Explorer), and some with yours, but there will still be cases with 1 hour difference in both. You could even get 2 hours and more when copying the file back+forth between NTFS and FAT (during different daylight saving periods).