I created the module in subject for an application I had to create for my job. I am planning to release it on CPAN
I already started to get some reviews from italian perl mongers, I would also like to have yours.
Below you have the man page I wrote so far.
You can also download the module for testing it from http://bugs.unica.it:4444/modules/
Cheers --bronto
NAME Date::Iterator - Iterate over a range of dates
SYNOPSIS use Date::Iterator;
# This puts all the dates from Dec 1, 2003 to Dec 10, 2003 in @dates
# @dates will contain ([2003,12,1],[2003,12,2] ... [2003,12,10]) ;
my $i1 = Date::Iterator->new(from => [2003,12,1], to => [2003,12,10]) ;
my @dates1 ;
push @dates,$_ while $_ = $i1->next ;
# Adding an integer step will iterate with the specified step
# @dates will contain ([2003,12,1],[2003,12,3] ... ) ;
my $i2 = Date::Iterator->new(from => [2003,12,1], to => [2003,12,10], step
=> 2) ;
my @dates2 ;
push @dates,$_ while $_ = $i2->next ;
ABSTRACT Date::Iterator objects are used to iterate over a range of dates, day by day or with a specified step. The method next() will return each time an array containing ($year,$month,$date) for the next date, or undef when finished.
DESCRIPTION new Creates a new object. You must pass it the end points of a date interval as hash references:
$i = Date::Iterator->new( from => [2003,12,1], to => [2003,12,10] )
"from" and "to" are, obviously, required.
Optionally, you can specify a custom step with the "step" key, for example:
$i = Date::Iterator->new( from => [2003,12,1], to => [2003,12,31], step => 7 ) ;
will iterate on December 2003, week by week, starting from December 1st.
next Returns the next date; in list context it returns an array containing year, month and day in this order, or "undef" if iteration is over; in scalar context, it returns a reference to that array, or "undef" if iteration is over.
HISTORY 0.01 Original version; created by h2xs 1.22 with options
-CAX -b 5.6.0 --use-new-tests --skip-exporter -O -v 0.01 Date::Iterator
SEE ALSO The wonderful Date::Calc module
AUTHOR Marco Marongiu, <[EMAIL PROTECTED]>
COPYRIGHT AND LICENSE Copyright 2003 by Marco Marongiu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.