Commit 18056921 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Don't treat timestamps in HH:MM format as tags

When you enter a todo item: "Call office at 09:00", the 09:00 would be
seen as a tag-value pair. Because of this, the timestamp would be
removed from the todo text: "Call office at ".

Discussed in issue #211.
parent be1e70cc
......@@ -377,5 +377,27 @@ class TodoBaseTester(TopydoTest):
todo = TodoBase("x 2017-07-01 2017-06-31 Invalid")
self.assertIsNone(todo.creation_date())
def test_timestamp_tag1(self):
todo = TodoBase("12:00")
self.assertFalse(todo.has_tag('12'))
self.assertEqual(todo.text(), '12:00')
def test_timestamp_tag2(self):
todo = TodoBase("12:00a")
self.assertTrue(todo.has_tag('12'))
self.assertEqual(todo.tag_value('12'), '00a')
self.assertEqual(todo.text(), '')
def test_timestamp_tag3(self):
todo = TodoBase("9:00")
self.assertFalse(todo.has_tag('9'))
self.assertEqual(todo.text(), '9:00')
def test_timestamp_tag4(self):
todo = TodoBase("009:00")
self.assertTrue(todo.has_tag('009'))
self.assertEqual(todo.tag_value('009'), '00')
self.assertEqual(todo.text(), '')
if __name__ == '__main__':
unittest.main()
......@@ -33,7 +33,7 @@ _NORMAL_HEAD_MATCH = re.compile(
r'(\((?P<priority>[A-Z])\) )?' + '((?P<creationDate>' + _DATE_MATCH +
') )?(?P<rest>.*)')
_TAG_MATCH = re.compile('(?P<tag>[^:]+):(?P<value>.+)')
_TAG_MATCH = re.compile(r'(?![0-9+]{1,2}:[0-9]{1,2}$)(?P<tag>[^:]+):(?P<value>.+)')
_PROJECT_MATCH = re.compile(r'\+(\S*\w)')
_CONTEXT_MATCH = re.compile(r'@(\S*\w)')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment