|
NAMETime::Interval - Converts time intervals of days, hours, minutes, and secondsThis is a rather simple perl module for dealing with time intervals. Among other things, this module can tell you the number of hours, minutes, and seconds elapsed between two dates. NOTE: this module does not handle resolutions < 1 second. Please see the Time::HiRes module for high resolution time operations. This module will round fractional second values to the nearest whole number. SYNOPSISuse Time::Interval; $data = getInterval( "1/25/03 12:34:32 EDT 2003", "4/25/03 11:24:00 EDT 2003" ); $string = getInterval( "1/25/03 12:34:32 EDT 2003", "4/25/03 11:24:00 EDT 2003", "string" ); $number_of_minutes = convertInterval( days => 5, hours => 23, minutes => 10, ConvertTo => "minutes" ); $data = parseInterval(seconds => 14295872); $string = parseInterval( seconds => 14295872, String => 1 ); $string = parseInterval( seconds => 14295872, Small => 1 ); $min_intervals = coalesce([ [ '1/25/03 12:34:32 EDT 2003', '1/25/03 15:34:32 EDT 2003' ], [ '1/25/03 14:34:32 EDT 2003', '1/25/03 16:34:32 EDT 2003' ], [ '1/25/03 09:10:18 EDT 2003', '1/25/03 12:32:15 EDT 2003' ] ]); getIntervalthis will take two date strings in any of the formats recognized by Date::Parse, and return the number of days, hours, minutes, and seconds elapsed between the two times.Returned Data formatgetInterval returns a hash reference in the same format as parseInterval.Catching exceptionsupon failure this routine will return the undef value, and an error string will be warn'd to stdout.Arguments
convertIntervalthis will convert a given number of days, hours, minutes, or seconds, or any combination thereof to the format specified by the ConverrtTo option.Returned datais a number, of time units that you specify on the ConvertTo optionOptions
parseIntervalthis will convert the given time interval to the number of days, hours, minutes and seconds.Returned Data Formatunless the 'String' option is specified, this routine returns a has reference containing the following data:\%data = ( 'days' => $number_of_days, 'hours' => $number_of_hours, 'minutes' => $number_of_minutes, 'seconds' => $number_of_seconds ); Options
coalescegiven a set of time intervals (start and end time pairs), this method will return the minimum set based on overlapping time spans. That is, this method will return a list of unique contiguous time intervals from the given list. As with the other methods in this package, time strings may be submitted in any of the formats supported by Date::Parse. Data is returned as it was passed in, as a reference to an array of array references (see below).Argumentscoalesce takes only one argument, an array reference. The reference should be to an array of array references, each of which contains a start and an end time. For a quick example, take a look at the SYNOPSIS section.Author:Andrew N. Hicox <ahicox@hicox.com> http://www.hicox.com
Visit the GSP FreeBSD Man Page Interface. |