remove @ prefix for timespecs
This commit is contained in:
parent
9ea2fbed41
commit
fac74e651a
10
Command.py
10
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
|
||||
|
10
test
10
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user