changeset 11:e1bec6dfd524

Improve start/end/days handling
author Daniel O'Connor <darius@dons.net.au>
date Fri, 22 Dec 2017 13:19:43 +0100
parents 3f5b617b4715
children 2b115732f4bc
files graph.py
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graph.py	Fri Dec 22 13:14:23 2017 +0100
+++ b/graph.py	Fri Dec 22 13:19:43 2017 +0100
@@ -67,17 +67,22 @@
 
     # Can specify..
     # Start and end
-    # Start and days
-    # End and days
+    # Start and days or Start
+    # End and days or End
     # Nothing
     # Want to end up with a start & end
-    if args.start is not None and args.end is not None:
+    selector = [args.start is not None, args.end is not None, args.days is not None]
+    if selector == [True, True, False]:
         pass
-    elif args.start is not None and args.days is not None:
+    elif selector == [True, False, True] or selector == [True, False, False]:
+        if args.days == None:
+            args.days = 1
         args.end = args.start + datetime.timedelta(days = args.days)
-    elif args.end is not None and args.days is not None:
+    elif selector == [False, True, True] or selector == [False, True, False]:
+        if args.days == None:
+            args.days = 1
         args.start = args.end - datetime.timedelta(days = args.days)
-    elif args.start is None and args.end is None and args.days is None:
+    elif selector == [False, False, True]:
         end = datetime.date.today()
         end = datetime.datetime(start.year, start.month, start.day)
         args.start = args.end - datetime.timedelta(days = args.days)