projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4bb4a18
)
[utils] Add "yesterday" as a date keyword
author
Philipp Hagemeister
<phihag@phihag.de>
Thu, 11 Dec 2014 09:29:30 +0000
(10:29 +0100)
committer
Philipp Hagemeister
<phihag@phihag.de>
Thu, 11 Dec 2014 09:29:30 +0000
(10:29 +0100)
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index a95d2c942f35dbbe1cd8402698b398b3a887d45a..75f9594e6c8abcecfe128af1be2e73575d6eecc1 100644
(file)
--- 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()
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
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')
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')