[CDBI] Time::Piece behaviour on CDBI::MySQL
karjala_lists at karjala.org
Fri May 5 19:22:43 BST 2006
Time::Piece has this functionality:
__PACKAGE__->autoinflate(dates => 'Time::Piece')
that translates dates from the database to Time::Piece and vice versa.
This module assumes that the times stored in the database are GMT times
(as opposed to local times).
A problem thus occurs when the times stored in the MySQL database are
The following problem, specifically: time differences ($t - $s) are
wrong. This program produces a big negative number instead of a number
close to 5 which would be expected (assume I live east of London):
$a = localtime;
$s = $row->time;
$t = localtime;
print $t - $s;
A way to solve this problem might be for the CDBI::MySQL developers to
set another parameter for the autoinflate method, that would tell the
module whether the times stored in the database are local times or GMT.
[In general, a Time::Piece object is GMT iff $t-> == 0, and local if
$t-> == 1]
More information about the ClassDBI