NAME
Date::Set - Date set math
SYNOPSIS
use Date::Set;
my $interval = Date::Set->new('20010501')->quantize(unit=>'months');
print "This month: ", $interval, "\n\n";
print "Weeks this month: ", $interval->quantize(unit=>'weeks'), "\n\n";
print "Tuesdays this month: ", $interval->quantize(unit=>'weeks')->
offset( mode => 'begin', unit=>'days', value => [ 2, 3] );
DESCRIPTION
Date::Set is a module for date/time sets.
It requires Date::ICal. If you don't need ICal functionality, use Set::Infinite instead.
METHODS
event
event()
Constructor. Returns 'forever', that is: (-Inf .. Inf)
period
period( time => [time1, time2] )
Another constructor. Returns [time1 .. time2]
dtstart
dtstart( start => time1 )
Returns set intersection [time1 .. Inf)
'dtstart' puts a limit when the event starts. If the event already starts AFTER dtstart, it will not change.
duration
duration( unit => months, duration => 10 )
All intervals are modified to 'duration'.
'unit' parameter can be years, months, days, weeks, hours, minutes, or seconds.
rrule
rrule ( BYMONTH => [ list ], BYWEEKNO => [ list ],
BYYEARDAY => [ list ], BYMONTHDAY => [ list ],
BYDAY => [ list ], BYHOUR => [ list ],
BYMINUTE => [ list ], BYSECOND => [ list ],
BYSETPOS => [ list ],
UNTIL => time, FREQ => freq, INTERVAL => n, COUNT => n )
Implements RRULE from RFC2445.
FREQ can be: SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY or YEARLY
BYDAY list may contain: SU MO TU WE TH FR SA
BYxxx items must be array references (must be bracketed): BYMONTH => [ 10 ] or BYMONTH => [ 10, 11, 12 ] or BYMONTH => [ qw(10 11 12) ]
(some documentation needed!)
occurrences
occurrences( period => date-set )
Returns the occurrences for a given period.
INHERITED METHODS
These methods are inherited from Set::Infinite.
Logic
$logic = $a->intersects($b);
$logic = $a->contains($b);
$logic = $a->is_null;
Set
$i = $a->union($b);
$i = $a->intersection($b);
$i = $a->complement;
$i = $a->complement($b);
$i = $a->span;
Scalar
$i = $a->min;
$i = $a->max;
$i = $a->size;
Other set methods
$a->real;
$a->integer;
quantize( parameters )
Makes equal-sized subsets.
select( parameters )
Selects set members based on their ordered positions.
Selection is more useful after quantization.
freq - default=1
by - default=[0]
interval - default=1
count - dafault=infinite
offset ( parameters )
Offsets the subsets.
value - default=[0,0]
mode - default='offset'. Possible values are: 'offset', 'begin', 'end'.
type($i)
chooses an object data type.
type('Set::Infinite::Date');
tolerance(0) defaults to real sets (default)
tolerance(1) defaults to integer sets
Note: 'unit' parameter can be years, months, days, weeks, hours, minutes, or seconds.
BUGS
'rrule' method is not yet full RFC2445 compliant.
'byday' does not understand (scalar . string) formats yet (like '-2FR')
'duration' and 'period' methods may change in future versions, to generate open-ended sets.
'bymonth' does not accept a negative value
'WKST' is not implemented yet
'byweekno' needs a 'weekyear' quantize unit to work properly. (See: Date::Tie)
AUTHOR
Flavio Soibelmann Glock <fglock@pucrs.br> with the Reefknot team.