From 453e34d7e6aff77d828fafef55231794d145c6d1 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@cervoi.se> Date: Wed, 18 Feb 2015 17:15:53 +0100 Subject: [PATCH] fix db date format --- Sam/commands/list.pm | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Sam/commands/list.pm b/Sam/commands/list.pm index a01826d..d90ee11 100644 --- a/Sam/commands/list.pm +++ b/Sam/commands/list.pm @@ -13,16 +13,16 @@ sub exec { my $sth; if ($chan->[0] =~ /^#/) { - $sth = $dbh->prepare_cached('SELECT id, title, date, place, description, link + $sth = $dbh->prepare_cached('SELECT id, title, DATE_FORMAT(date, "%d/%m/%Y"), place, description, link FROM sam - WHERE date > ? + WHERE date > NOW() ORDER BY date LIMIT 2' ); } else { - $sth = $dbh->prepare_cached('SELECT id, title, date, place, description, link + $sth = $dbh->prepare_cached('SELECT id, title, DATE_FORMAT(date, "%d/%m/%Y"), place, description, link FROM sam - WHERE date > ? + WHERE date > NOW() ORDER BY date' ); } @@ -32,7 +32,7 @@ sub exec { return; } - $sth->execute(scalar time) + $sth->execute() or $log->error("Couldn't finish transaction: " . $dbh->errstr); if (!$sth->rows) { @@ -41,12 +41,7 @@ sub exec { } while ($row = $sth->fetch) { - my (undef, undef, undef, $day, $month, $year, undef, undef, undef) = - localtime($row->[2]); - $month++; - $year += 1900; - - $msg = "[".$row->[0]."] ".$row->[1]." le $day/$month/$year"; + $msg = "[".$row->[0]."] ".$row->[1]." le ".$row->[2]; $msg .= " @ ".$row->[3] if ($row->[3]); $msg .= " : ".$row->[4] if ($row->[4]); $msg .= " <".$row->[5].">" if ($row->[5]); -- GitLab