[ic] UserDB Last Login bug when running with mysql
Carl Bailey
carl at triangleresearch.com
Fri Jun 2 12:42:19 EDT 2006
Using IC 5.4, we noticed that the user's last login time in the UI was
showing up as December 1969 for everyone. We traced the issue to this:
The mysql column type is timestamp, which returns the data like
YYYYMMDDHHMMSS.
However the UI page customer_view.html uses a [time] tag to display the
value. The problem is that the time tag only works correctly when
given a "unix" time value, and fails when given the mysqlvalue above.
We solved it by changing the UI page as follows:
[calc]
my $dt = "[loop-param mod_time]";
$dt =~ m/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
return "$2/$3/$1 $4:$5:$6"
[/calc]
However, this fix works only for mysql and does not allow such flexible
formatting as the time tag.
A more general fix would be to adjust the time tag something along the
lines that follow:
-- use POSIX qw(ceil strftime LC_CTYPE);
++ use POSIX qw(ceil mktime strftime LC_CTYPE);
my $now = $opt->{time} || time;
++ if (length($now) == 14) {
++ # we have a mysql timestamp on our hands
++ $now = m/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
++ my $now = mktime($6,$5,$4,$3,$2 - 1,$1 - 1900);
++}
More information about the interchange-users
mailing list