Time::Avail - A Perl module to calculate time availability.
use Time::Avail;
$minRemaining = timeAvailable( $timeStartStr, $timeEndStr, $dayMask );
The timeAvailable function compares the time interval specified by timeStartStr, timeEndStr, and dayMask with the current day and time. timeAvailable returns 0 if the current day and time do not fall within the specified time interval, otherwise the number of minutes remaining is returned. timeStartStr and timeEndStr are string parameters that must adhere to a HH:MM 24 hour format, where HH represents a two digit hour value and MM represents a two digit minute value. dayMask is a bitmask which specifies the valid days for the time interval.
The dayMask parameter is constructed by OR'ing together one or more of the following dayMask constants:
Time::Avail::DAY_MONDAY
Time::Avail::DAY_TUESDAY
Time::Avail::DAY_WEDNESDAY
Time::Avail::DAY_THURSDAY
Time::Avail::DAY_FRIDAY
Time::Avail::DAY_SATURDAY
Time::Avail::DAY_SUNDAY
Time::Avail::DAY_WEEKDAY
Time::Avail::DAY_WEEKEND
Time::Avail::DAY_EVERYDAY
To calculate the time remaining given a starting time of 5am and an ending time of 5pm for Sunday and Monday, the call to timeAvailable can be coded as follows:
$minRemaining = timeAvailable( "05:00", "17:00", Time::Avail::DAY_SUNDAY | Time::Avail::DAY_MONDAY );
To calculate the time remaining given a starting time of 10:30am and an ending time of 7:45pm for Saturday, Sunday, and Monday, the call to timeAvailable can be coded as follows:
$minRemaining = timeAvailable( "10:30", "19:45", Time::Avail::DAY_SATURDAY | Time::Avail::DAY_SUNDAY |Time::Avail::DAY_MONDAY );
or
$minRemaining = timeAvailable( "10:30", "19:45", Time::Avail::DAY_WEEKEND | Time::Avail::DAY_MONDAY );
To calculate the time remaining given a starting time of 7am and an ending time of 7pm for everyday but Saturday and Sunday, the call to timeAvailable can be coded as follows:
$minRemaining = timeAvailable( "07:00", "19:00", Time::Avail::DAY_WEEKDAY );
To calculate the time remaining given a starting time of 10pm and an ending time of 2am for everyday, the call to timeAvailable can be coded as follows:
$minRemaining = timeAvailable( "22:00", "02:00", Time::Avail::DAY_EVERYDAY );
1.00
Version 1.00 ------------ - Released.
Peter Santoro peter@pscomp.com
Copyright (c) 1998 Peter Santoro. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself; however, you must leave this copyright statement intact.
December 19, 1998
This distribution can be also be found at the author's web site:
http://www.connix.com/~psantoro/
To install Time::Avail, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Time::Avail
CPAN shell
perl -MCPAN -e shell install Time::Avail
For more information on module installation, please visit the detailed CPAN module installation guide.