Having some trouble with Perl's DateTime package -- essentially trying to periodically query a MySQL db for the nearest time stamp and compare it with the current time, to see how much time there is before the next "event".
The correct record is chosen via the SQL query, so no worries there. Here's the date comparison code:
my $now = DateTime->now(time_zone => 'America/New_York');
my $then = DateTime::Format::MySQL->parse_datetime($last);
print "NOW: ";
print "THEN: ";
my $diff = $then->delta_ms($now);
...where the $last var corresponds to the MySQL record's datetime format. The conversion to Perl's DateTime object seems to go ok, as can be seen by this output..
[root@localhost directory]# ./sql-test.pl
SQL: 2009-10-06 18:00:00
But the problem is that I want to compare the diff in minutes, and as can be seen above, the day is ignored in the comparison. yes, there are more than just minutes in the diff, but between the delta_ms and in_minutes calls the larger time blocks should be converted to minutes. Any idea what's going on here, I'm banging my head against the keyboard...