{ package DateTime::Event::Predict; use DateTime::Event::ICal; use strict; sub new { my ($class, %params) = @_; my $dts = DateTime::Set->from_datetimes( dates => $params{dates} ); for my $freq ( qw[ yearly monthly weekly daily hourly minutely secondly ] ) { my $dtr = DateTime::Event::ICal->recur( freq => $freq, dtstart => $params{dates}[0] ); return $dtr if $dtr->contains( $dts ); } return $dts; }
} # SYNOPSIS # use DateTime::Event::Predict; use DateTime::Format::ICal; my $dtr = DateTime::Event::Predict->new( dates => [ DateTime->today, DateTime->today->add( months => 1 ) ] ); print DateTime::Format::ICal->format_recurrence($dtr); # note: format_recurrence() doesn't print 'DTSTART', but the recurrence values are correct =head1 CREDITS Based on an idea from Steffen Mueller <[EMAIL PROTECTED]> =head1 COPYRIGHT Copyright (c) 2008 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut