NAME

Calendar::Slots - Manage time slots

VERSION

version 0.01

SYNOPSIS

use Calendar::Slots;
my $cal = new Calendar::Slots;
$cal->slot( date=>'2009-10-11', start=>'10:30', end=>'11:30', name=>'busy' ); 
my $slot = $cal->find( date=>'2009-10-11', time=>'11:00' );
print $slot->name;    # 'busy'

DESCRIPTION

This is a simple module to manage a calendar of very generic time slots. Time slots are anything with a start and end time on a given date or weekday. Time slots cannot overlap. If a new time slot overlaps another pre-existing time slot, the calendar will acommodate the slot automatically.

It handles two types of slots: fixed dates, or recurring on weekdays. When looking for an event, it will search from most specific (date) to more generic (recurring). That is, if a slot exist for both a date and a weekday, it returns the date slot only.

The calendar is able to compact itself and generate rows that can be easily stored in a file or database.

LIMITATIONS

Some of it current limitations:

  • No overlapping of time slots.

  • If a time-slot spans over midnight, two slots will be created, one for the selected date until midnight, and another for the next day from midnight until end-time.

  • It does not handle timezones.

  • It does not know of daylight-savings or any other DateTime features.

METHODS

slot ( name=>Str, { date=>'YYYY-MM-DD' | weekday=>1..7 }, start=>'HH:MM', end=>'HH:MM' )

Add a time slot to the calendar.

If the new time slot overlaps an existing slot with the same name, the slots are merged and become a single slot.

If the new time slot overlaps an existing slot with a different name, it overwrites the previous slot, splitting it if necessary.

find ( { date=>'YYYY-MM-DD' | weekday=>1..7 }, time=>'HH:MM' )

Returns a Calendar::Slots::Slot object for a given .

$cal->find( weekday=>1, time=>'11:30' );   # find what's on Monday at 11:30

name

Shortcut method to find a slot and return a name.

sorted

Returns a ARRAY of all slot objects in the calendar.

all

Returns an ARRAY of all slot objects in the calendar.

TODO

There are many improvements planned for this module, as this is just an ALPHA release that allows me to get somethings done at $work...

  • Other types of recurrence: first Monday, last Friday of September...

  • Merge several calendars into one.

  • Create subclasses of Calendar::Slots::Slot for each slot type.

  • Better input formatting based on DateTime objects and the such.

AUTHOR

Rodrigo de Oliveira rodrigolive@gmail.com

LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 258:

You forgot a '=back' before '=head1'