Commit d22c4bc7 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add 'yesterday' as a relative date

parent 6bb804dc
......@@ -26,6 +26,7 @@ from topydo.lib.RelativeDate import relative_date_to_date
class RelativeDateTester(TopydoTest):
def setUp(self):
super(RelativeDateTester, self).setUp()
self.yesterday = date(2015, 11, 5)
self.today = date(2015, 11, 6)
self.tomorrow = date(2015, 11, 7)
self.monday = date(2015, 11, 9)
......@@ -115,6 +116,14 @@ class RelativeDateTester(TopydoTest):
result = relative_date_to_date('tom')
self.assertEqual(result, self.tomorrow)
def test_yesterday1(self):
result = relative_date_to_date('yesterday')
self.assertEqual(result, self.yesterday)
def test_yesterday2(self):
result = relative_date_to_date('yes')
self.assertEqual(result, self.yesterday)
def test_monday1(self):
result = relative_date_to_date('monday')
self.assertEqual(result, self.monday)
......
......@@ -91,7 +91,7 @@ def relative_date_to_date(p_date, p_offset=None):
The following formats are understood:
* [0-9][dwmy]
* 'today' or 'tomorrow'
* 'yesterday', 'today' or 'tomorrow'
* days of the week (in full or abbreviated)
"""
result = None
......@@ -126,4 +126,7 @@ def relative_date_to_date(p_date, p_offset=None):
elif re.match('tom(orrow)?$', p_date):
result = _convert_pattern('1', 'd')
elif re.match('yes(terday)?$', p_date):
result = _convert_pattern('-1', 'd')
return result
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