Is there an easy way to apply an offset to the time attr?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
strider
Junior Member
Junior Member
Posts: 4
Joined: 2003-03-13, 07:17 UTC

Is there an easy way to apply an offset to the time attr?

Post by *strider »

Is there an easy way in Total Commander to apply an offset to the time attribute of a file?

For example, I travel with my digi-cam and often forget to set the internal clock to match the new timezone. I want the file timestamps to reflect the local time at the moment I take the picture. So I want to apply, say, a two or three hour offset from the current hour timestamped on the file.

Typical timestamp utils fail because the new value isn't an offset from the current value.

If, heaven forbid, TC can't do it, any recommendations for one that can? :wink:

Thanks!

strider
User avatar
norfie
Power Member
Power Member
Posts: 1194
Joined: 2003-02-18, 14:18 UTC

Post by *norfie »

Last edited by norfie on 2004-09-10, 19:24 UTC, edited 1 time in total.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Yepp, AddTime from http://thehacker.host.sk/addtime/ :D

BTW: It's on the AddOns page of www.ghisler.com now, too.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

After I tried ReDate, I decided to try AddTime :)... and also one bug hasn't bypassed my attention :). Here it is:

I selected several files/dirs and specified to add 1 year and to subtract 1 day. Your app done this, and additionaly it added 2 seconds almost to all the files (26 out of 32). Probably it's some bonus! :)
I repeated the test and results were absolutely the same, so it's persistent bug, must be easy to find.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Mmm, rather sounds like some rounding thing of the 2-sec precision of FAT or something like that, since the routine to do the time changes is:

Code: Select all

for i := 0 to filelist.Count - 1 do
  begin
    date := filedatetodatetime(fileage(filelist[i]));

    date := incyear(date, YearsSpinEdit.Value);
    date := incmonth(date, MonthsSpinEdit.Value);
    date := incday(date, DaysSpinEdit.Value);
    date := inchour(date, HoursSpinEdit.Value);
    date := incminute(date, MinutesSpinEdit.Value);
    date := incsecond(date, SecondsSpinEdit.Value);

    filesetdate(filelist[i], datetimetofiledate(date));
  end;
As you see, there should be no bug... well, you can check the source, too. ;)

Thanks
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

Unfortunately (or fortunately :) ) I don't have any Pascal sources compiling tools, nor I have API manuals for Pascal (I didn't find neither datetimetofiledate, nor filedatetodatetime, nor incxxxx functions in WinAPI manual), moreover I never wrote in Pascal (although syntax is quite clear). Try the test I described on NTFS, can you reproduce it? If yes, then you can run the program step-by-step and discover what function does that bad... :)
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

I didn't find neither datetimetofiledate, nor filedatetodatetime, nor incxxxx functions in WinAPI manual

Those are Delphi functions so you won't find them in the Windows API.


Try the test I described on NTFS, can you reproduce it?

Yes.


If yes, then you can run the program step-by-step and discover what function does that bad...

I can't since my development environment is W98SE at home... :(

Thanks
Roman
User avatar
wanderer
Power Member
Power Member
Posts: 1578
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Post by *wanderer »

Hacker wrote:I can't since my development environment is W98SE at home... :(
Well, a quick and dummy way to create a "debugging" environment is to display a messagebox after the call of each function, to see what values it returns. Then you compile the source code and use it in an NTFS environment compiled. You try the same with the same files in an Win98 environment and you see which value is different in the two environments. Dum but it should work (taking into consideration all the +-1 hr for daylight savings and other differences between FAT and NTFS).

Ciao...
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3
x64: Clients/Servers from Win7 to Win11 and Win2K12Srv to Win2K22Srv, mainly Win10 though.
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

Roman,
awcdelphi.exe and awcwinapi.exe both work as before: values displayed in the temporary message boxes are valid but on disk I still receive the 2-second bonus :).
prectime.exe works fine, it sets valid both seconds and milliseconds.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

awcdelphi.exe and awcwinapi.exe both work as before: values displayed in the temporary message boxes are valid but on disk I still receive the 2-second bonus.

What?!? How? I mean, What?!? How? Err... so you're saying that the times in the messageboxes are fine (ie the second and third timestamps are the same) but the ones on disk are not?

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

Hacker wrote:What?!? How? I mean, What?!? How?
You were so amazed that I checked this again more attentively. :)
Example: modification time of some file was "05.06.2003 17:53:42.329" (last 3 digits are milliseconds). After I applied AddTime with "+1 year" task the file's ModfifyTime became "05.06.2004 17:53:44.000". Your temp msg box showed the following:

Code: Select all

c:\tipa papka takaja\tipa tozhe\tipa fajlo takoe.txt
Previous date: 05.06.2003 17:53:44
New date should be: 05.06.2003 17:53:44
New date is: 05.06.2003 17:53:44
As you can see I was a bit wrong saying "values displayed in the temporary message boxes are valid". PrevTime is not valid (in my previuos test I was paying attention to "should be" and "is" times). So the dog is in getting the time. Seems that Delphi function you use rounds up the time: it sees 329 milliseconds and snaps to the next FAT's "time quantum". So the conclusion: drop this buggy Delphi and move to C++ and plain WinAPI! :lol: (joke)

The reason why some files are handled OK (remember, I wrote that 6 files don't receive 2-second makeweight) is that they have even number of seconds and 0 milliseconds.

Nevertheless one note: TC is also written in Delphi, therefore it must be using the same time function as your AddTime, but it snaps to the previous "time quantum"??? (TC displays "05.06.2003 17:53:42.329" time as "05.06.2003 17:53:42, whereas AddTime displays it as "05.06.2003 17:53:44")

Second note: What kind of WinAPU do you use in awcwinapi.exe? :) WinAPI's GetFileTime or FindFirstFile return valid times but awcwinapi.exe displays wrong ones...
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

OK, great, thank you, that finally shed some light onto the whole matter.
The problem seems to be in getting the time - I am still doing this using Delphi functions, I am using winapi only to set the time. I'll try getting the time through winapi, too, and see if it works, but the time manipulations - I am afraid it would be a lot of work if they didn't work, so I hope it's enough to use winapi for getting and setting the time.

BTW: Are you sure the info in the [ code ] box is correct? Especially the year in the New date...?

Thanks
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hey again Valentino,
Please try http://thehacker.host.sk/myfiles/testft2dt.zip . It gets the timestamp using GetFileTime and then converts it to Delphi's own format. I'd like to see if that works for a start.
BTW: How do you get the exact filetime on a NTFS system? Alt-Enter doesn't show the milliseconds, for instance.

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

An updated version - http://thehacker.host.sk/myfiles/testplus1year.zip - also tests adding one year to the date.

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply