The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DateTime::Schedule::Weekly - Determine scheduled days in range based on weekly recurrence and inclusions/exclusions

SYNOPSIS

  use DateTime::Schedule::Weekly;

  my $dts = DateTime::Schedule::Weekly->weekdays(exclude => [...list of school holidays...], portion => 0.5);

  my $school_days_elapsed = $dts->days_in_range($first_day_of_school, $now)->count;

DESCRIPTION

This subclass of DateTime::Schedule augments its capabilities to support a regular weekly schedule of on/off days.

CONSTRUCTORS

new

Returns a new instance. Permits the following construction parameters, in addition to those supported by DateTime::Schedule:

sunday, monday, tuesday, wednesday, thursday, friday, saturday

Optional. Default true

These seven constructor parameters indicate which days of the week are "scheduled" By default, all are "on", making the behavior identical to DateTime::Schedule's.

include

Optional. Default []

An arrayref of DateTimes. These days are included over and above the normal schedule.

E.g., a school schedule could be regularly M-F, but due to extensive weather-related closures, the school added in one or more saturdays class days. These would be included.

N.B. Exclusions have priority over inclusions, so a date in both lists will be excluded!

weekdays

Identical to calling "new" except that by default saturday and sunday are "off".

weekends

Identical to calling "new" except that by default monday, tuesday, wednesday, thursday, and friday are "off".

METHODS

Implements all methods from DateTime::Schedule

AUTHOR

Mark Tyrrell <mark@tyrrminal.dev>

LICENSE

Copyright (c) 2024 Mark Tyrrell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.