Support querying only yesterday and today
authorJoey Schulze <joey@infodrom.org>
Tue, 2 Feb 2021 17:47:17 +0000 (18:47 +0100)
committerJoey Schulze <joey@infodrom.org>
Tue, 2 Feb 2021 17:49:00 +0000 (18:49 +0100)
src/InfoCon/stempel/stempel

index ec2c4fb..f57499a 100755 (executable)
@@ -270,9 +270,13 @@ sub list
     } elsif ($month =~ /^(\d\d?)$/) {
        my $pivot = $d_year+1900 . '-' . $1 . '-01';
        $query .= "AND start >= '$pivot' AND start <= '$pivot'::date + interval '1 month' ";
-    } elsif (length $month && $month !~ /^all$/) {
+    } elsif (length $month && $month eq 'today') {
+       $query .= "AND start::date = now()::date ";
+    } elsif (length $month && $month =~ /^yester(day)?$/) {
+       $query .= "AND start::date = (now() - interval '1 day')::date ";
+    } elsif (length $month && $month !~ /^(all|current)$/) {
        $query .= "AND task LIKE '%${month}%' ";
-    } elsif ($month !~ /^all$/) {
+    } elsif ($month !~ /^all$/ || $month eq 'current') {
        my $pivot = sprintf('%04d-%02d-01', $d_year+1900, $d_mon+1);
        $query .= "AND start >= '$pivot' AND start <= '$pivot'::date + interval '1 month' ";
     }
@@ -371,7 +375,7 @@ sub help
 {
     print <<"END";
 stempel  Copyright (c) 2007,8  Martin Schulze <joey\@infodrom.org>
-    --list [month] list month [default=current|all]
+    --list [month] list month [default=current|all|yesterday|today]
     --back n       move start of current task back by n minutes
     --open         list open
     --close time   close open task