<<

NAME

Koha::Calendar - Object containing a branches calendar

VERSION

This documentation refers to Koha::Calendar version 0.0.1

SYNOPSIS

  use Koha::Calendar

  my $c = Koha::Calendar->new( branchcode => 'MAIN' );
  my $dt = DateTime->now();

  # are we open
  $open = $c->is_holiday($dt);
  # when will item be due if loan period = $dur (a DateTime::Duration object)
  $duedate = $c->addDate($dt,$dur,'days');

DESCRIPTION

  Implements those features of C4::Calendar needed for Staffs Rolling Loans

METHODS

new : Create a calendar object

my $calendar = Koha::Calendar->new( branchcode => 'MAIN' );

The option branchcode is required

addDate

    my $dt = $calendar->addDate($date, $dur, $unit)

$date is a DateTime object representing the starting date of the interval.

$offset is a DateTime::Duration to add to it

$unit is a string value 'days' or 'hours' toflag granularity of duration

Currently unit is only used to invoke Staffs return Monday at 10 am rule this parameter will be removed when issuingrules properly cope with that

addHours

    my $dt = $calendar->addHours($date, $dur, $return_by_hour )

$date is a DateTime object representing the starting date of the interval.

$offset is a DateTime::Duration to add to it

$return_by_hour is an integer value representing the opening hour for the branch

addDays

    my $dt = $calendar->addDays($date, $dur)

$date is a DateTime object representing the starting date of the interval.

$offset is a DateTime::Duration to add to it

$unit is a string value 'days' or 'hours' toflag granularity of duration

Currently unit is only used to invoke Staffs return Monday at 10 am rule this parameter will be removed when issuingrules properly cope with that

single_holidays

my $rc = $self->single_holidays( $ymd );

Passed a $date in Ymd (yyyymmdd) format - returns 1 if date is a single_holiday, or 0 if not.

is_holiday

$yesno = $calendar->is_holiday($dt);

passed a DateTime object returns 1 if it is a closed day 0 if not according to the calendar

days_between

$duration = $calendar->days_between($start_dt, $end_dt);

Passed two dates returns a DateTime::Duration object measuring the length between them ignoring closed days. Always returns a positive number irrespective of the relative order of the parameters

next_open_day

$datetime = $calendar->next_open_day($duedate_dt)

Passed a Datetime returns another Datetime representing the next open day. It is intended for use to calculate the due date when useDaysMode syspref is set to either 'Datedue' or 'Calendar'.

prev_open_day

$datetime = $calendar->prev_open_day($duedate_dt)

Passed a Datetime returns another Datetime representing the previous open day. It is intended for use to calculate the due date when useDaysMode syspref is set to either 'Datedue' or 'Calendar'.

set_daysmode

For testing only allows the calling script to change days mode

clear_weekly_closed_days

In test mode changes the testing set of closed days to a new set with no closed days. TODO passing an array of closed days to this would allow testing of more configurations

add_holiday

Passed a datetime object this will add it to the calendar's list of closed days. This is for testing so that we can alter the Calenfar object's list of specified dates

DIAGNOSTICS

Will croak if not passed a branchcode in new

BUGS AND LIMITATIONS

This only contains a limited subset of the functionality in C4::Calendar Only enough to support Staffs Rolling loans

AUTHOR

Colin Campbell colin.campbell@ptfs-europe.com

LICENSE AND COPYRIGHT

Copyright (c) 2011 PTFS-Europe Ltd All rights reserved

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

<<