Date::Step - A basic date iterator
use Date::Step my $step = Date::Step->new(); # new object $step->set_start('20051008'); # start date $step->set_end('20061008'); # end date $step->set_increment('1d12h'); # date increment length $step->set_format('%Y %B %e'); # format of returned date string my $date; do { $date = $step->get_current(); print "$date\n"; } while ($step->next());
Date::Step is a basic date iterator class.
Date::Step
Returned dates are done so using the convention set up by the Unix 'date' program:
B = January...December b = Jan...Dec d = Padded day of month; 01-{28,29,30,31} e = zero padded day of month 1-{28,29,30,31} h = Jan...Dec k = padded hour of day; 00-23 l = zero padded hour of dayl 0-23 m = padded month; 01-12 Y = four digit year y = two digit year; 00-99
The default start date is Jan 1 1900, but there is no reason why the date can't be set earlier than that. If there is a max date, it is probably after the year 9999. =head1 AUTHOR
Brett D. Estrade - <estrabd AT mailcan DOT com>
Write some tests and more useful documentation.
This module handles hours as the smallest division of time. If you wish to have a more fine grained capability, please let me know.
I am not sure how robust this module is to doing things like changing the format or the increment amount arbitrarily through out the iterative generation of daytes, but I do not see why it would cause problems. The only issue that might possibly come up would be losing some time during the transition phase. Again, I don't know bc I have not tested it.
There is no "previous" date, but it would probably be a neat features.
Please send reports to me.
Bug reports who supply patches for a cool new feature or a bug fix get there name here :)
This code is released under the same terms as Perl.
To install Date::Step, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Date::Step
CPAN shell
perl -MCPAN -e shell install Date::Step
For more information on module installation, please visit the detailed CPAN module installation guide.