Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

(ichimunki) re: Date processor

by ichimunki (Priest)
on Feb 23, 2001 at 22:50 UTC ( [id://60525]=note: print w/replies, xml ) Need Help??


in reply to Date processor

This might not be a bad way to go if you are the only one who ever uses this script. But I'd think a series of splits combined with a clear "if" rather than the embedded ? will make the code a lot clearer and perhaps execute more quickly.
my $time_stamp = "2-19-01 3:22 PM"; my($date, $time, $am_pm) = split(/ /, $time_stamp); my($month, $day, $short_year) = split(/-/, $date); my($hours, $min) = split(/:/, $time); if ($am_pm =~ /pm/i) { $hours += 12; } my $year = 2000 + short_year; my $sql_time_stamp = "$year-$month-$day $hours:$min"
I know this looks a lot more like "baby talk Perl", but ask yourself which one you can read more easily without background info. Also ask yourself which one is easier to change if your date format (into or out of this function) ever changes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-25 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found