From: Will Budic Date: Wed, 19 Feb 2020 21:23:03 +0000 (+1100) Subject: Bug 19 fix. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=6a71dfb8cdb967fbe612835b185bceb5dc036112;p=LifeLog.git Bug 19 fix. --- diff --git a/Current Development Check List.md b/Current Development Check List.md index 9f3feb1..cb9a762 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -79,7 +79,7 @@ This version is not compatible in data structure to prior versions. Data migrati ### v. 1.8 Encountered/Fixed -* Bug 19 - Same day datediff is displaying wrong report in time stack on the page. +* ✔ Bug 19 - Same day datediff is displaying wrong report in time stack on the page. * ✔ Issue 18 - Setting excludes for views, deliveres page but long delays with server finished exchange (page doesn't hang). * The page is server delivered, if sections contain external internet links, this timeouts page browser delivery if the internet is down. * ✔ Bug 17 - Editing of entries on occasions, duplicates entries. diff --git a/htdocs/cgi-bin/data.cgi b/htdocs/cgi-bin/data.cgi index cd83e1f..56b93a0 100755 --- a/htdocs/cgi-bin/data.cgi +++ b/htdocs/cgi-bin/data.cgi @@ -6,13 +6,14 @@ use strict; use warnings; -use Try::Tiny; use Switch; use CGI; use CGI::Session '-ip_match'; use DBI; +use Exception::Class ('LifeLogException'); +use Syntax::Keyword::Try; use DateTime qw(); use DateTime::Format::SQLite; @@ -37,14 +38,14 @@ if(!$userid||!$dbname){ my $database = Settings::logPath().$dbname; my $dsn= "DBI:SQLite:dbname=$database"; -my $db = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die "

Error->"& $DBI::errstri &"

"; +my $db = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or LifeLogException->throw($DBI::errstri); #Fetch settings my $imgw = 210; my $imgh = 120; Settings::getConfiguration($db); Settings::getTheme(); - +my $human = DateTime::Format::Human::Duration->new(); ### Page specific settings Here @@ -104,18 +105,21 @@ sub DisplayDateDiffs{ $stm = $stm." OR "; } } - $stm .= ';'; + $stm .= ' ORDER BY PID;'; print $cgi->pre("###[stm:$stm]") if($DEBUG); $st = $db->prepare( $stm ); - $st->execute() or die or die "

Error->"& $DBI::errstri &"

"; + $st->execute(); my ($dt,$dif,$first,$last,$tnext, $dt_prev) = (0,0,0,0,0,$today); while(my @row = $st->fetchrow_array()) { - - $dt = DateTime::Format::SQLite->parse_datetime( $row[0] ); + my $rdat = $row[0]; + my $rlog = $row[1]; + $rlog =~ m/\n/; + $dt = DateTime::Format::SQLite->parse_julianday( $rdat ); + $dt->set_time_zone(&Settings::timezone); $dif = dateDiff($dt_prev, $dt); $tbl .= ''. $dt->ymd . ' - '.$row[1]."". + '.$rlog."". ''.$dif.' '; $last = $dt_prev; $dt_prev = $dt; @@ -136,18 +140,23 @@ print '
'.$tbl.'

Back to Main Lognew(); - my $dur = $span->format_duration($d2 - $d1); - my $t = " today "; - $t = "" if ($d1!=$today); -return sprintf( "%s
between $t $ff %s and %s", $dur, boldDate($d1), boldDate($d2)); + my($d1,$d2,$ff,$sw)=@_; + if($d1->epoch()>$d2->epoch()){ + $sw = $d1; + $d1 = $d2; + $d2 = $sw; + }else{$sw="";} + my $dur = $human->format_duration_between($d1, $d2); + my ($t1,$t2) = ("",""); + $t1 = " today " if ($d1->ymd() eq $today->ymd());# Notice in perl == can't be used here! + $t2 = " today " if ($d2->ymd() eq $today->ymd()); +return sprintf( "%s
between $ff $t1 %s and $t2 %s[%s]", $dur, boldDate($d1), boldDate($d2), $d1->ymd()); } sub boldDate { my($d)=@_; -return "".$d->ymd." ".$d->hms; +return "".$d->ymd()." ".$d->hms; }