diff options
-rw-r--r-- | perc | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -294,7 +294,7 @@ def combination_pairs(first, second): return combined -def parseDatetime(datetimestring): +def parseDatetime(datetimestring, today_relative=False): date_formats = CONFIG["FORMAT"]["date"].values() time_formats = CONFIG["FORMAT"]["time"].values() combined_formats = combination_pairs(date_formats, time_formats) @@ -302,6 +302,9 @@ def parseDatetime(datetimestring): for format in date_formats + time_formats + combined_formats: try: t = datetime.strptime(datetimestring, format) + if today_relative: + t = datetime.combine(NOW.date(), t.time()) + return t, format except ValueError: pass @@ -345,15 +348,15 @@ def parseUserArgs(args, user): times = args[0:1] if len(times) == 1: - finish, format = parseDatetime(times[0]) + finish, format = parseDatetime(times[0], True) elif len(times) >= 2: - start, format = parseDatetime(times[0]) - finish, format = parseDatetime(times[1]) + start, format = parseDatetime(times[0], True) + finish, format = parseDatetime(times[1], True) if options.start: - start, format = parseDatetime(options.start) + start, format = parseDatetime(options.start, True) if options.finish: - finish, format = parseDatetime(options.finish) + finish, format = parseDatetime(options.finish, True) if format: start_formatted = start.strftime(format) @@ -584,6 +587,10 @@ def user(args): (options, args) = parser.parse_args(args) + if isWeekend(): + print "It's the freekin' Weekend!!!!" + sys.exit(0) + if options.version: print "v%s" % VERSION sys.exit(0) @@ -603,10 +610,6 @@ def user(args): def main(): readConfig() - if isWeekend(): - print "It's the freekin' Weekend!!!!" - sys.exit(0) - args = sys.argv[1:] if "perc" in args: args.remove("perc") |