SPUG: Date::Manip infinite loop
Yitzchak Scott-Thoennes
sthoenna at gmail.com
Sat Jan 12 23:57:25 PST 2013
No bug here; DateCalc is expecting a date/time in your local timezone
as input and outputing a date/time in your local timezone, but does
the math on the actual UTC time. So you add 24 hours to 2012-11-04
(midnight assumed) and get 2012-11-04 23:00:00; then you throw away
the time part
before the next iteration.
On Sat, Jan 12, 2013 at 2:36 PM, Joel Grow <joel at largest.org> wrote:
> Hello SPUG gurus,
>
> I'm stumped as to why the code below gets into an infinite loop on November
> 4, 2012. I tried starting $current_date at Jan 1, 2011, and it gets into an
> infinite loop on November 6, 2011. This is on a linux box running perl
> 5.10.1. When I run it on another linux box running 5.8.8, it works fine.
> Any idea what's going on? Thanks!
>
> -J
>
>
> use strict;
> use Date::Manip;
>
> my $current_date = '2012/01/01';
>
> while (Date_Cmp($current_date, '2012/12/31')) {
> print "Current date is: $current_date\n";
> $current_date = UnixDate(DateCalc($current_date, "+1 days"),
> "%Y/%m/%d");
> }
>
> print "Bye!\n";
>
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays
> WEB PAGE: http://seattleperl.org/
More information about the spug-list
mailing list