in reply to Re: time as number
in thread time as number

Just use that -- print localtime -- sort by it, do compares

Er, I dont think thats right:

D:\perl\PerlToc>perl -e "print ''.localtime" Mon Mar 3 18:12:15 2003
Which doesn't provide a sortable format. Unless you want your dates sorted by day of week :-)

---
demerphq


Replies are listed 'Best First'.
Re: Re: Re: time as number
by Cody Pendant (Prior) on Mar 03, 2003 at 21:55 UTC
    But surely you've forced scalar context on it there by making it a string. What happens if you just do "print localtime"? And anyway, who needs localtime anyway. You can just do it with time and local it, again, later when you need your human-readable format.
    --
    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D

      But surely you've forced scalar context on it there by making it a string. What happens if you just do "print localtime"?

      You would end up sorting by second first etc... And reversing it doesn't help. Don't forget that localtime() returns

      ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time +);
      in list context.

      You can just do it with time and local it, again, later when you need your human-readable format.

      Yup. That works much better. ;-) Although personally I find that YYYYMMDDHHMMSS can be a quite useful representation of time.

      ---
      demerphq