TimeSampleHistogram: add option for N days ago
authorDan White <dan@whiteaudio.com>
Thu, 31 Aug 2017 18:27:15 +0000 (13:27 -0500)
committerDan White <dan@whiteaudio.com>
Thu, 31 Aug 2017 18:27:15 +0000 (13:27 -0500)
TimeSampleHistogram

index f0d3c7639be2d2e99363cb5fa4a6e0ab5551cd31..572c9d421f8e27d506781c03b29df9ca851a96a2 100755 (executable)
@@ -38,6 +38,8 @@ parser.add_option('-t', '--today', dest='today', action='store_true',
                   help='show today only', default=False)
 parser.add_option('-y', '--yesterday', dest='yesterday', action='store_true',
                   help='show yesterday only', default=False)
+parser.add_option('-a', '--days-ago', dest='daysago', action='store',
+                  help='show for N days ago', metavar='N', type='int')
 parser.add_option('-w', '--width', dest='width', type='int',
                   help='width of report', metavar='W', default=PRINT_WIDTH)
 parser.add_option('-n', '--numer', dest='numsort', action='store_true',
@@ -101,6 +103,9 @@ elif opt.today:
 elif opt.yesterday:
     startdate = enddate = dt.date.today() - dt.timedelta(1)
 
+if isinstance(opt.daysago, int):
+    startdate = enddate = dt.date.today() - dt.timedelta(opt.daysago)
+
 # handle -d, --days option
 # if supplied, modify either startdate or enddate accordingly
 if opt.days > 0: