From 51e9872f4ac5db633c12862dec951e0b91b1b132 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Thu, 31 Mar 2016 20:44:38 +0200 Subject: NMS: Fix historic review, part one The actual replay might still be bugged, but fixed-point review works. --- include/nms/web.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/nms') diff --git a/include/nms/web.pm b/include/nms/web.pm index 889e774..7c9339e 100755 --- a/include/nms/web.pm +++ b/include/nms/web.pm @@ -15,7 +15,7 @@ package nms::web; use base 'Exporter'; our %get_params; our %json; -our @EXPORT = qw(finalize_output json $dbh db_safe_quote %get_params get_input %json); +our @EXPORT = qw(finalize_output now json $dbh db_safe_quote %get_params get_input %json); our $dbh; our $now; our $when; @@ -66,7 +66,7 @@ sub setwhen { $offset = $_[1]; } if (defined($get_params{'now'})) { - $now = db_safe_quote('now') . "::timestamp "; + $now = db_safe_quote('now') . "::timestamp with time zone "; $cc{'max-age'} = "3600"; } $now = "(" . $now . " - '" . $offset . "'::interval)"; @@ -77,10 +77,10 @@ sub finalize_output { my $query; my $hash = Digest::SHA::sha512_base64(FreezeThaw::freeze(%json)); $dbh->commit; - $query = $dbh->prepare('select to_char(' . $now . ', \'YYYY-MM-DD"T"HH24:MI:SS\') as time;'); + $query = $dbh->prepare('select extract(epoch from date_trunc(\'seconds\', ' . $now . ')) as time;'); $query->execute(); - $json{'time'} = $query->fetchrow_hashref()->{'time'}; + $json{'time'} = int($query->fetchrow_hashref()->{'time'}); $json{'hash'} = $hash; printcc; -- cgit v1.2.3