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

Re^2: Converting 24 hour time back into 12 hour

by jfroebe (Parson)
on Nov 07, 2004 at 16:57 UTC ( [id://405903]=note: print w/replies, xml ) Need Help??


in reply to Re: Converting 24 hour time back into 12 hour
in thread Converting 24 hour time back into 12 hour

hi,

slight correction:

sub to12h { local $_=shift; if (($_ < 0) || ($_ > 23)) { return ("$_ is not a valid hour"); } return ($_, "AM") if $_ < 12; return ($_, "PM") if $_ == 12; return ($_ -12, "PM") } for (0..23) { print join " ", to12h($_), "\n"; }

Jason L. Froebe

Team Sybase member

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Replies are listed 'Best First'.
Re^3: Converting 24 hour time back into 12 hour
by theorbtwo (Prior) on Nov 07, 2004 at 17:02 UTC
    Thanks.
Re^3: Converting 24 hour time back into 12 hour
by Lana (Beadle) on May 27, 2013 at 03:31 UTC
    one more correction - you have forgot to convert 24hr's 00 hours to 12AM
    sub to12h { local $_=shift; if (($_ < 0) || ($_ > 23)) { return ("$_ is not a valid hour"); } return (12, "AM") if $_ == 0; return ($_, "AM") if $_ < 12; return ($_, "PM") if $_ == 12; return ($_ -12, "PM"); } for (0..23) { print join " ", to12h($_), "\n"; }
      there is no such thing as 24:00hrs...

Log In?
Username:
Password:

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

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

    No recent polls found