Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: time difference

by BrowserUk (Patriarch)
on Aug 01, 2005 at 04:51 UTC ( #479791=note: print w/replies, xml ) Need Help??


in reply to time difference

Ignore this. It doesn't work! Please downvote.

See POSIX for strftime and perlfunc for localtime, -C & -M

### BAD CODE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! use POSIX qw[ strftime ]; print strftime "%d : %H : %M : %S\n", localtime( ( -C 'file' ) - -M _ +); 01 : 00 : 00 : 47

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.

Replies are listed 'Best First'.
Re^2: time difference
by rob_au (Abbot) on Aug 01, 2005 at 04:58 UTC
    See the update to my own node in this thread - -C is inode change time, not (universally) file creation time - The inode creation time may roughly equate with the file creation time or that of a permission change for the file.

     

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

Re^2: time difference
by sk (Curate) on Aug 01, 2005 at 05:36 UTC
    A simple question but somehow it seems to be confusing the heck out of me!

    I tried your code BrowserUK on UNIX and things did not come out well so I switched to Windows XP PRO.

    Here is what I did

    (Note: I changed your 'file' to 'junk')

    1. I created a file with some content

    2. After a few minutes i added some more content

    3. I ran the timestamp program

    I see funny results. No matter the file, i get the same result

    . Can you throw some light?

    C:\>echo hi > junk C:\>dir junk 7/31/2005 10:25 PM 5 junk 1 File(s) 5 bytes 0 Dir(s) 15,975,989,248 bytes free C:\>echo hi2 >> junk C:\>dir junk 07/31/2005 10:28 PM 11 junk 1 File(s) 11 bytes 0 Dir(s) 15,975,989,248 bytes free C:\>perl timestamp 1 : 16 : 00 : 00

    I am on activstate

    C:\>perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail)

    When I run the program on UNIX i get  31 : 18 : 00 : 00 as output

    Any thoughts?

    thanks

    SK

      Two problems.

    • First I forgot that -C -A & -M give their results in days rather than seconds like every other timestamp.
    • Second, the days will always be +1 (because days of the month start from 1) and it would only work for values less than 31 (number of days in January).

      Original posts updated to reflect my laxity.


      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://479791]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2022-06-25 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (81 votes). Check out past polls.

    Notices?