in reply to Increment through date range by day with only standard modules.
General approach I'd use: Use Time::Local and localtime to alternate between epoc time and a more standard time format. (Add days in epoc time, convert to standard, use, then convert back to epoc at a specific time of day and start over.)
I'll leave the actual code as an exercise. ;)
use Time::Local; my $date_epoc = timelocal(0,0,12,23,11,2007); my $end_date = timelocal(0,0,12,12,4,2008); my @date_array; push @date_array, '2008-11-23'; while ( $date_epoc < $end_date ) { # Might want <= instead: I'd have +to check. $date_epoc = $date_epoc + 86400; my (undef, undef, undef, $day, $mon, $year) = localtime($date_epoc) +; push @date_array, "$year-$mon-$day"; $date_epoc = timelocal(0,0,12,$day,$mon,$year); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Increment through date range by day with only standard modules.
by ikegami (Patriarch) on Dec 12, 2008 at 20:26 UTC | |
by DStaal (Chaplain) on Dec 12, 2008 at 20:35 UTC | |
by ikegami (Patriarch) on Dec 12, 2008 at 20:59 UTC | |
by dbmathis (Scribe) on Dec 12, 2008 at 21:22 UTC | |
|
Re^2: Increment through date range by day with only standard modules.
by dbmathis (Scribe) on Dec 12, 2008 at 19:59 UTC |