in reply to Getting avg start time
Get the time - but set the date to the same date every time to get a comparison.
Remember you want to compare times not dates and times so yoiu need to take the date out of the equation.
#!/bin/perl ## UNTESTED use strict; use warnings; use Date::Calc qw(Date_to_Time); use POSIX; my $time1 = Date_to_Time(2007,1,1,23,00,0); my $time2 = Date_to_Time(2007,1,1,03,00,0); my $time3 = Date_to_Time(2007,1,1,01,00,0); print "$time1\t$time2\t$time3\n"; my $avg = sprintf "%0.0f", (($time1+$time2+$time3)/3); print "$avg\n"; print strftime "%H:%M:%S\n", gmtime($avg);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Getting avg start time
by Earindil (Beadle) on Aug 09, 2007 at 16:15 UTC |
In Section
Seekers of Perl Wisdom