LISTSERV mailing list manager LISTSERV 16.0

Help for LINUX-L Archives


LINUX-L Archives

LINUX-L Archives


LINUX-L@LISTS.UFL.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LINUX-L Home

LINUX-L Home

LINUX-L  2007

LINUX-L 2007

Subject:

Re: 12h to 24h time in perl

From:

John Gelnaw <[log in to unmask]>

Reply-To:

[log in to unmask]

Date:

Fri, 12 Oct 2007 09:29:00 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (23 lines)

On Fri, 2007-10-12 at 08:13 -0400, Mauricio Tavares wrote:
> 	What would be the best way to convert time given in a 12h clock
> (as in 12:52 AM) format into 24h clock (00:52) using perl? I have a file
> full of data which was recorded in that format and would like to convert
> it to the 24h style...
> 
> ...unless there is a clever way to feed that right into gnuplot. ;)

Well, I wouldn't say it's the *best* way, and I'd still recommend the
cpan module...

But if you want brute force, this seems to work OK.  :)

while(<>)  {
    s/(\d+):(\d+) ([AP]M)/$1%12+(12*($3 eq "PM")).":$2"/e;
    s/(\d):/0$1:/;
    print;
}


-- 
John Gelnaw <[log in to unmask]>
CITS, McKnight Brain Institute

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997

ATOM RSS1 RSS2



LISTS.UFL.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager