Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: time difference

by rob_au (Abbot)
on Aug 01, 2005 at 04:47 UTC ( #479789=note: print w/ replies, xml ) Need Help??


in reply to time difference

Untested code follows ... Update: Bugger, caught out on inode change/creation time - Remember that (stat _)[10] (or -C _) is not file creation time, but rather inode change time.

sub diff { return -1 unless -e $_[0]; my @result = (); my $diff = ((stat _)[10]) - ((stat _)[9]); foreach my $time ((86400, 3600, 60, 1)) { push @result, $diff % $time; $diff -= $result[-1]; } return @result; }

 

perl -le "print unpack'N', pack'B32', '00000000000000000000001000000000'"


Comment on Re: time difference
Select or Download Code
Re^2: time difference
by mifflin (Curate) on Aug 01, 2005 at 05:02 UTC
    Is there a reliable way to get the true file creation time given that -C (and stat 10) is not it?
      Not in Unix. The Unix founders argue (and I agree) that "creation time" is at best an odd concept. But you didn't say on what platform, so you may be able to get a "fake" creation time proposed by your platform.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        The Unix founders argue (and I agree) that "creation time" is at best an odd concept.

        Care to explain that?

        dir thisfile File not found. echo . > thisfile dir thisfile 01/08/2005 06:38 4 thisfile

        The file was created. The time tells you when it was created. How is that false or ambiguous?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://479789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-12-25 11:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls