diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-12-11 10:29:30 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-12-11 10:29:30 +0100 |
commit | f8795e102b35198db550432c2eee43a1c2571093 (patch) | |
tree | 846cd8cf6754b0ee8a520543104376e42264a50c /youtube_dl/utils.py | |
parent | 4bb4a18876f5489db77365528638da8d46890a38 (diff) |
[utils] Add "yesterday" as a date keyword
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index a95d2c942..75f9594e6 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -712,8 +712,10 @@ def date_from_str(date_str): Return a datetime object from a string in the format YYYYMMDD or (now|today)[+-][0-9](day|week|month|year)(s)?""" today = datetime.date.today() - if date_str == 'now'or date_str == 'today': + if date_str in ('now', 'today'): return today + if date_str == 'yesterday': + return today - datetime.timedelta(days=1) match = re.match('(now|today)(?P<sign>[+-])(?P<time>\d+)(?P<unit>day|week|month|year)(s)?', date_str) if match is not None: sign = match.group('sign') |