Commit 80114fff authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge branch 'master' into colorblock

parents f97a19f6 54db080a
......@@ -90,5 +90,29 @@ class TodoTest(TopydoTest):
todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02")
self.assertEqual(todo.length(), 1)
def test_length4(self):
todo = Todo("(C) Foo)")
self.assertEqual(todo.length(), 0)
def test_length5(self):
todo = Todo("(C) 2015-11-18 Foo)")
self.assertEqual(todo.length(), 0)
def test_length6(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-19)")
self.assertEqual(todo.length(), 1)
def test_length7(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-18)")
self.assertEqual(todo.length(), 0)
def test_length8(self):
todo = Todo("(C) 2015-11-18 Foo t:2015-11-19 due:2015-11-20)")
self.assertEqual(todo.length(), 1)
def test_length9(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-16)")
self.assertEqual(todo.length(), 0)
if __name__ == '__main__':
unittest.main()
......@@ -85,9 +85,10 @@ class Todo(TodoBase):
def length(self):
"""
Returns the length (in days) of the task, by considering the start date
and the due date. Returns 0 when one of these dates are missing.
and the due date. When there is no start date, its creation date is
used. Returns 0 when one of these dates is missing.
"""
start = self.start_date()
start = self.start_date() or self.creation_date()
due = self.due_date()
if start and due and start < due:
......
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