No announcement yet.

Folder Date Math ??

  • Filter
  • Time
  • Show
Clear All
new posts

  • Jim Padgett
    My Bad for not posting the entire code segment, but I'm getting a warm fuzzy about the process at least... if the logic was too flawed I'd have heard by now.
    I must confess I have been away from coding for some time.. I love doing it.. but sometimes I feel like I spend way too much time just getting what I think are the simplest things to work like they should.

    Many Thanks to M.M. and everyone here... this forum is the real value in PB .. not to slight you Bob Z ... if the compiler wasn't so good the forum wouldn't be so good either.

    I'll have to check the entire piece out tomorrow when I get back to work.

    Leave a comment:

  • Michael Mattias
    >ftq.q = FData.LastWriteTime
    Last write time is not available for folders,ever. (as 'last write time' anyway)
    A FILETIME structure. For a file, the structure specifies when the file was last written to. For a directory, the structure specifies when the directory was created. If the underlying file system does not support last write time, ftLastWriteTime is zero.
    That said, try casting your constants as QUADs, as you may be getting overflows:
    %one_ft_second  = 10000000&&
    %one_ft_minute   = 60&& * %one_ft_second
    %one_ft_hour     =  60&& * %one_ft_minute
    %one_ft_day      =  24&& * %one_ft_hour

    Duh, wait a minute...

    >D$ = Dir$("C:\TEMP\")

    You need to use your DIRDATA variable ("Fdata") in this statement. Your 'Fdata' variable is never set to anything.


    Leave a comment:

  • Jim Padgett
    Confused by this Time thing!!!!

    This is what I get...

    cdq.q = 1.2877041783947E+17
    ftq.q = 1.28564550852129E+17

    The folder was created on Jan 14, 2009 at 09:35:39 AM

    My result is 238

    Seems I missing the Big Picture here somewhere .. not unusuall for me

    Leave a comment:

  • Michael Mattias
    Looks like the right path to me.

    You really can't get around using FileTimes, since DIR$/FindFirstFile are always in UTC, and if you get that file from another time zone you can get really messed up.

    I think you should not use that "loc" in your variable names... suggests to me that you are working in LOCal times, when in fact you are working totally in UTC. Probably no big deal today, but if you don't look at that routine for six months you are going to wonder why you refer to "local" times in your variables but never use, say, the FileTimeToLocalFileTime() or GetLocalTime() functions.

    And unless you want to deal in decimal fractions of days, I'd change to integer division ("\") to replace the floating-point division ("/")


    Leave a comment:

  • Jim Padgett
    started a topic Folder Date Math ??

    Folder Date Math ??

    Am I on the right track?
    %one_ft_second = 10000000
    %one_ft_minute = 60 * %one_ft_second
    %one_ft_hour = 60 * %one_ft_minute
    %one_ft_day = 24 * %one_ft_hour
    Union ftunion		
    	q  As Quad
     	ft As filetime
    End Union
    Dim  FData As DIRDATA
    Local ftq As ftUnion     
    Local cdq As ftUnion
    Local sLocTime As SystemTime 
    Dim DayDiff&&
    D$ = Dir$("C:\TEMP\")
    GetSystemTime sLocTime          ' Place Current SystemTime to sLocTime struct?
    SystemTimeToFileTime sLocTime, cdq.ft        ' Take SystemTime convert to Filetime place in cdq.ft 
    ftq.q = FData.LastWriteTime
    Would this give me age of folder in days ?

    DayDiff&& = (cdq.q - ftq.q) / %one_ft_day

    I could easily create a file and use the time for that and skip the SystemTime stuff, but I'm really trying to not use shortcuts.. so to speak