From fac74e651a40c66613a949ecf553cdeb3aa8fd00 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 29 Dec 2010 00:22:30 -0500 Subject: [PATCH] remove @ prefix for timespecs --- Command.py | 10 +++++++--- test | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Command.py b/Command.py index 0f72efc..e02a9bc 100644 --- a/Command.py +++ b/Command.py @@ -25,8 +25,7 @@ class Command: parts = cmdline.split(None, 1) if len(parts) > 1: timespec = parts[0].strip() - if timespec[0] == '@': - self.time = self.parseTimeSpec(timespec[1:]) + if self.parseTimeSpec(timespec): parts = parts[1].split(None, 1) if len(parts) == 1: command = parts[0].strip() @@ -41,6 +40,7 @@ class Command: def parseTimeSpec(self, timespec): the_time = self.time + matched = False m = re.match('^(?:(\d{4})[-/])?(\d{1,2})[-/](\d{1,2}),(.+)$', timespec) if m is not None: # a date was given @@ -62,6 +62,7 @@ class Command: elif len(am_pm) >= 1 and am_pm[0] == 'a' and h == 12: h = 0 the_time = the_time.replace(hour = h, minute = mins, second = 0) + matched = True else: m = re.match('^([-+])(\d+(?:\.\d+)?)([hms])?$', timespec, re.I) if m is not None: @@ -80,4 +81,7 @@ class Command: the_time -= delta else: the_time += delta - return the_time + matched = True + if matched: + self.time = the_time + return matched diff --git a/test b/test index f3f2534..8d3d4ce 100755 --- a/test +++ b/test @@ -28,16 +28,16 @@ def main(): testcmd('out', 'out', '') testcmd('fill', 'fill', '') testcmd('adjust', 'adjust', '') - testcmd('report', 'report', '') + testcmd('2 report', 'report', '') testcmd('show', 'show', '') - testcmd('@5pm out', 'out', '') + testcmd('5pm out', 'out', '') testcmd('show 45h', 'show', '45h') testcmd('fill 40h', 'fill', '40h') - testcmd('arlx', 'start', 'arlx') + testcmd('-10m arlx', 'start', 'arlx') testcmd(' adjust -10m ', 'adjust', '-10m') - testcmd(' @9:45 wr: nog: pbit ram test ', + testcmd(' 9:45 wr: nog: pbit ram test ', 'start', 'wr: nog: pbit ram test') - testcmd('@12/14,3pm start arlx', 'start', 'arlx') + testcmd('12/14,3pm start arlx', 'start', 'arlx') if n_tests == n_pass: print " >= SUCCESS <=" else: