1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

A couple of new plugins

Discussion in 'Plugins' started by Charles Dye, Apr 28, 2010.

  1. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
  2. Jay Sage

    Joined:
    Jun 2, 2008
    Messages:
    284
    Likes Received:
    1
    Charles,

    I just tried to play with your new plugins, but they won't install --
    because (I assume) I'm running the 64-bit version of TCMD. Can you
    generate 64-bit versions? If I install the 32-bit version of TCMD, would
    they then run, even under the 64-bit Windows 7?

    -- Jay
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    Sorry, but I don't have any 64-bit systems to test with. I presume that 32-bit TC would run under 64-bit Windows, but again, I have no way of trying it myself.
     
  4. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    I like it. It would be even more useful if the display of a timestamp could be modified to include the time offset being used for it, something like
    Code:
    Created:                  15-Nov-2009           15:23:52 -0500
    Modified:                 29-Apr-2010            11:26:43 -0400
    Accessed:                29-Apr-2010            11:26:43 -0400
    
    Perhaps even an option to display the times in UTC.
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    I honestly can't think of any better way to do that than to get both localized and UTC times, then subtract....

    That wouldn't be difficult, but would it really be useful?
     
  6. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    | ---Quote (Originally by dcantor)---
    || I like it. It would be even more useful if the display of a
    || timestamp could be modified to include the time offset being used
    || for it, something like
    | ---End Quote---
    | I honestly can't think of any better way to do that than to get both
    | localized and UTC times, then subtract....
    |
    | ---Quote---
    || Perhaps even an option to display the times in UTC.
    | ---End Quote---
    | That wouldn't be difficult, but would it really be useful?

    Variable functions @FILEDATE and @FILETIME have the UTC option since V9.
    What would be much more useful to me is a way to force all conversions
    between the stored UTC and corresponding local time based on the time
    difference in effect at the time of the event, so the time a picture of
    sunrise was taken would be reported the same no matter when I view it. I
    have many files named according to their original timestamp using
    4DOS/4NT/TCC batch files. When I try to merge files to a backup device,
    using the /U option of TCC's COPY, I may overwrite gigabytes of unmodified
    files with themselves due to the virtual timestamp change when one of the
    devices is NTFS but not the other.
    --
    Steve
     
  7. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    (offset indication)
    That's surprising. I had assumed you must have had to figure out what the correct offset from UTC *was* for the selected timestamp in order to get the localized value. But thanks for considering it.

    (UTC times)
    Sometimes. Not often. I can always do
    Code:
    echo %@filetime[file,u]
    Again, thanks for considering it.
     
  8. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    Something like this, perhaps? http://www.unm.edu/~cdye/plugins/iso8601.html#f_filestamp
     
  9. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    No, just checking the underlying filesystem and calling the correct APIs accordingly.
     
  10. dbartt

    Joined:
    May 29, 2008
    Messages:
    36
    Likes Received:
    0
    Charles Dye wrote:

    I'm a bit confused about this. AFIK the NTFS file system does not record the DST
    UTC offset in effect at the "event" time so how is it possible to reconstruct
    the true event time without figuring out what the UST offset was? Would you
    share what the "correct" APIs are to do this?

    Dennis
     
  11. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    The magic call is SystemTimeToTzSpecificLocalTime(), which converts a UTC time (which is how timestamps are stored in NTFS) to a local time, taking into account the local timezone and whether or not DST was in force at that point in time.

    But while this seems to be the right way to handle NTFS timestamps, it's definitely not the right thing for FAT filestamps, which store the local time to begin with.
     
  12. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
  13. dbartt

    Joined:
    May 29, 2008
    Messages:
    36
    Likes Received:
    0
    I'm pretty sure that SystemTimeToTzSpecificLocalTime uses the current DST
    setting for the specified zone rather than that of the time being converted.

    Quoting from the MS help:

    "The SystemTimeToTzSpecificLocalTime function takes into account whether
    daylight saving time (DST) is in effect for the local time to which the system
    time is to be converted."

    No mention of historical DST value.



    And this quote:
    "The SystemTimeToTzSpecificLocalTime function may calculate the local time
    incorrectly under the following conditions:
    * The time zone uses a different UTC offset for the old and new years.
    * The UTC time to be converted and the calculated local time are in
    different years."

    This implies an inability to adjust for different event and local time zones,
    and no knowledge of historical DST settings.

    Dennis
     
  14. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    I used this function in my DIR replacement and it will display the same time
    for a file all year round, unlike explorer and the standard CMD/TCC DIR
    calls. All those agree with each other but files switch times twice a year.

    --
    Jim Cook
    2010 Sundays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Monday.
     
  15. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    You're interpreting that statement the exact opposite of the way I'm reading it. Which means that it isn't very well-written, I suppose; but the function does give the correct answer in my testing.

    As far as I know, the UTC offsets for United States time zones have never been changed. That's probably true of Canada, Mexico, and western Europe as well. I don't know what country prompted that caveat, but it doesn't worry me.
     
  16. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    But the dates at which DST is in effect have changed, individual counties (e.g., in Indiana) have moved from Eastern to Central time (or the reverse), and there have been years when DST was in effect year-round.

    I doubt there's any perfect solution to the problem.

    I think this plugin helps a great deal.
     
  17. dbartt

    Joined:
    May 29, 2008
    Messages:
    36
    Likes Received:
    0
    Agreed. I was only trying to clarify that while the plugin can return a
    consistent, non-changing event time, it cannot return the original, local event
    time without knowing both the original time zone and DST setting. The plugin
    provides a time stamp that doesn't change twice a year which is a great improvement.
     
  18. dbartt

    Joined:
    May 29, 2008
    Messages:
    36
    Likes Received:
    0
    And this quote:

    But computers can change time zones. If I'm traveling and choose to reset my
    computer's time zone to local time then all my NTFS file times will shift.
     
  19. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,286
    Likes Received:
    39
    Yes, indeed they will, no matter which APIs you use. And FAT filestamps won't. Isn't Windows a constant source of wonder and delight?
     

Share This Page