Interval(3)
π Interval(3) β Time::Interval π
okay bestie, so this is Time::Interval, a page from the User Contributed Perl Documentation, and it converts time intervals of days, hours, minutes, and seconds. it's a rather simple perl module for dealing with time intervals, fr fr. 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 please please see the Time::HiRes module for high resolution time operations. also β this module will round fractional second values to the nearest whole number. that's the vibe, no negotiating π
β¨ SYNOPSIS β¨
use 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' ]
]);
πΈ getInterval πΈ
this 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. iconic behavior honestly π«Ά
π Returned Data format
getInterval returns a hash reference in the same format as parseInterval.
π Catching exceptions
upon failure this routine will return the undef value, and an error string will be warn'd to stdout. so like, watch out for that π
π Arguments
- argument 1 (required) β this should be a date string in any of the formats available to
Date::Parse. - argument 2 (required) β this should be a date string in any of the formats available to
Date::Parse. - argument 3 (optional) β this argument controls how the interval will be returned. if not defined, the interval will be returned as a hash reference containing the number of days, hours, minutes and seconds between the two dates. if the following values are specified the interval will be returned as a string:
'small'β if this value is specified, a string containing abbreviated values will be returned (dhms format) for instance1d 2h 3m 0s(one day, two hours, three minutes and 0 seconds) π'string'β if this value (or any value other than'short') is specified a string containing the interval will be returned for instance:'1 day, 2 hours, 3 minutes, 0 seconds'
π¦ convertInterval π¦
this will convert a given number of days, hours, minutes, or seconds, or any combination thereof to the format specified by the ConverrtTo option.
π Returned data
is a number, of time units that you specify on the ConvertTo option. just a number. slay β¨
π Options
ConvertTo 'days'|'hours'|'minutes'|'seconds'β convert the given time interval to this unit of time measurement, if not specified, the default value is'seconds'daysβ specify number of dayshoursβ specify number of hoursminutesβ specify number of minutessecondsβ specify number of seconds
π§ parseInterval π§
this will convert the given time interval to the number of days, hours, minutes and seconds.
π Returned Data Format
unless 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
daysβ specify number of dayshoursβ specify number of hoursminutesβ specify number of minutessecondsβ specify number of secondsStringβ if this option is specified as a non-zero value a string containing the number of days, hours, minutes, and seconds is returned, for example:
"70 days, 16 hours, 56 minutes, 18 seconds"
Smallβ if this option is specified as a non-zero value a string containing the number of days, hours, minutes, and seconds is returned in abbreviated form (dhms format), for example:
"70d 16h 56m 18s"
π coalesce π
given 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). main character energy, honestly π
π Arguments
coalesce 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
and that's the whole thing bestie, you ate π this was Interval(3) from perl v5.42.0, dated 2025-07-25 β go forth and compute intervals, you gorgeous genius π«Άβ¨πΈ
π¦ where this page comes from
- fedora 43: perl-Time-Interval 1.234-25.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms