Show file time independent of daylight saving setting

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
tcdailyuser
Junior Member
Junior Member
Posts: 5
Joined: 2006-02-06, 09:47 UTC

Show file time independent of daylight saving setting

Post 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.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post 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.
Author of Total Commander
https://www.ghisler.com
User avatar
fenix_productions
Power Member
Power Member
Posts: 1979
Joined: 2005-08-07, 13:23 UTC
Location: Poland
Contact:

Re: Show file time independent of daylight saving setting

Post by *fenix_productions »

2tcdailyuser
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 :)
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...

#128099
tcdailyuser
Junior Member
Junior Member
Posts: 5
Joined: 2006-02-06, 09:47 UTC

Post 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
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post 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.
Author of Total Commander
https://www.ghisler.com
tcdailyuser
Junior Member
Junior Member
Posts: 5
Joined: 2006-02-06, 09:47 UTC

Post 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)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post 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).
Author of Total Commander
https://www.ghisler.com
Post Reply