diff options
author | Alasdair Colley <ac@brede.(none)> | 2011-11-01 11:41:04 +0000 |
---|---|---|
committer | Alasdair Colley <ac@brede.(none)> | 2011-11-01 11:41:04 +0000 |
commit | 2cf22773a3a5a60432d8c63a23a6bd557b9dccff (patch) | |
tree | 648ce3628cb3c7ae0b4ce968d2d99961b2d149eb | |
parent | 48fa0864aaa9c9f79e90b3db4a85081b0c1bce58 (diff) |
Fixed bug with perc <start> | <start> <end> command
-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") |