Mercurial > ~darius > hgwebdir.cgi > vanlogger
diff graph.py @ 17:57dece5674e3
Be more clever about what 'today' is
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Fri, 23 Feb 2018 15:14:15 +1030 |
parents | 29a61ec4755b |
children | 4d97dfb07169 |
line wrap: on
line diff
--- a/graph.py Fri Feb 23 15:04:59 2018 +1030 +++ b/graph.py Fri Feb 23 15:14:15 2018 +1030 @@ -66,6 +66,11 @@ if args.days is not None and args.days < 0: parser.error('days must be non-negative') + # If it's before 6am then plot yesterday + today = datetime.date.today() + if datetime.datetime.now().hour < 6: + today -= datetime.timedelta(days = 1) + selector = [args.start is not None, args.end is not None, args.days is not None] if selector == [True, True, False]: # Start and end pass @@ -78,11 +83,11 @@ args.days = 1 args.start = args.end - datetime.timedelta(days = args.days) elif selector == [False, False, True]: # Days - args.end = datetime.date.today() + datetime.timedelta(days = 1) + args.end = today + datetime.timedelta(days = 1) args.end = datetime.datetime(args.end.year, args.end.month, args.end.day) args.start = args.end - datetime.timedelta(days = args.days) elif selector == [False, False, False]: # Nothing - args.start = datetime.date.today() + args.start = today args.start = datetime.datetime(args.start.year, args.start.month, args.start.day) args.end = args.start + datetime.timedelta(days = 1) else: