Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > add half an hour to all times in file

Reply
Thread Tools

add half an hour to all times in file

 
 
Dan Jacobson
Guest
Posts: n/a
 
      09-24-2003
$ cat file
18:25
18:56
$ perl -wlpe 'Please tell me what to write here to get the following' file
18:55
19:26
Maybe perldoc Date:arse has something to do with this.
In Unix I can do $ date +%H:%M -d '22:22 + 30 minutes'.
 
Reply With Quote
 
 
 
 
Tore Aursand
Guest
Posts: n/a
 
      09-24-2003
On Wed, 24 Sep 2003 12:56:18 +0800, Dan Jacobson wrote:
> Maybe perldoc Date:arse has something to do with this.


Indeed. What went wrong when you tried to use it?


--
Tore Aursand <>

"You know the world is going crazy when the best rapper is white, the best
golfer is black, France is accusing US of arrogance and Germany doesn't
want to go to war."
 
Reply With Quote
 
 
 
 
Frank Maas
Guest
Posts: n/a
 
      09-24-2003

"Dan Jacobson" <> schreef in bericht
news:...
> $ cat file
> 18:25
> 18:56
> $ perl -wlpe 'Please tell me what to write here to get the following' file
> 18:55
> 19:26


perl -wlpe 'my ($h,$m)=split(/:/); my $t=($h*60)+$m+30; $h=int($t/60)%24;
$m=$t%60; $_=sprintf "%02d:%02d",$h,$m;'

--Frank


 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      09-24-2003
Dan Jacobson wrote:
>
> $ cat file
> 18:25
> 18:56
> $ perl -wlpe 'Please tell me what to write here to get the following' file
> 18:55
> 19:26
> Maybe perldoc Date:arse has something to do with this.
> In Unix I can do $ date +%H:%M -d '22:22 + 30 minutes'.



$ perl -e'
use Time::Local;
my @times = qw/ 18:25 18:56 23:42 /;
for my $time ( @times ) {
print "$time ";
$time = join":",(gmtime(timegm(0,(reverse $time=~/\d+/g),(gmtime)[3,4,5])+1800))[2,1];
print "$time\n";
}
'
18:25 18:55
18:56 19:26
23:42 0:12



John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
function reading hour register either in 12 or 24 hour formats andreturning properly ssylee C Programming 4 01-01-2008 03:11 AM
SimpleDateformat: 12 hour versus 24 hour techshiv@gmail.com Java 2 06-01-2007 09:51 PM
Re: 24 hour <--> 12 hour vcr clock fred@nospam.com Computer Support 0 08-14-2004 07:26 AM
24 hour <--> 12 hour vcr clock fred@nospam.com Computer Support 4 08-13-2004 01:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57