Re: Module submission DateTime::Event::Predict

[email protected] ("Flavio S. Glock")
Newsgroups perl.datetime
Message-ID <[email protected]>
{
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.