Skip to content

Commit

Permalink
Merge 42532ec into 71fb7e1
Browse files Browse the repository at this point in the history
  • Loading branch information
Randy Barlow committed Mar 2, 2016
2 parents 71fb7e1 + 42532ec commit 0e971ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions did/base.py
Expand Up @@ -273,6 +273,11 @@ def period(argument):
until = Date("today")
until.date += delta(days=1)
period = "today"
elif "yesterday" in argument:
since = Date("yesterday")
until = Date("yesterday")
until.date += delta(days=1)
period = "yesterday"
elif "year" in argument:
if "last" in argument:
since, until = Date.last_year()
Expand Down
6 changes: 6 additions & 0 deletions tests/test_base.py
Expand Up @@ -53,6 +53,12 @@ def test_Date_period():
from did.base import Date
today = did.base.TODAY
did.base.TODAY = datetime.date(2015, 10, 3)
# yesterday
for argument in ["yesterday"]:
since, until, period = Date.period(argument)
assert unicode(since) == "2015-10-02"
assert unicode(until) == "2015-10-03"
assert period == "yesterday"
# This week
for argument in ["", "week", "this week"]:
since, until, period = Date.period(argument)
Expand Down

0 comments on commit 0e971ae

Please sign in to comment.