Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sorting Puzzle

by imp (Priest)
on Feb 20, 2007 at 21:08 UTC ( #601208=note: print w/ replies, xml ) Need Help??


in reply to Sorting Puzzle

The numbers are too large for numeric comparison without using bigint


Comment on Re: Sorting Puzzle
Re^2: Sorting Puzzle
by willfould (Novice) on Feb 20, 2007 at 21:19 UTC
    Thank you! I am creating a numeric sorting key on start/end dates and times. I was originally wanting to convert the times to unix timestamp but could not find a fast way to do that. With the unix timestamp, this would be trivial but require the extra conversion step. Is there a datetime to unix timestamp function?
      Time::Piece makes it fairly easy, but you would have to benchmark it against other solutions to see what works for you. How much data are you dealing with?
      use Time::Piece; use strict; use warnings; my $date = '20070301103000'; my $start = Time::Piece->strptime($date, "%Y%m%d%H%M%S")->epoch; print $start, "\n";
      Datetime. It also provides sorting. It also provides intervals which sounds like what you're interested in.

      Less applicable to the question but more important, imho, is that it handles all the nasty edgecases that any developer who didn't write Datetime shouldn't be bothered to know about handling dates and times. This would include the situations when a minute can have 59 seconds, 61 seconds, and even 62 seconds. (Yes, those situations do exist in really odd circumstances, but it would suck if you accidentally ran into one of them, right?)


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-08-29 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls