From 37254abc36695692649348099fae0ed8f73fd3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Sun, 28 Apr 2013 11:39:37 +0200 Subject: Allow to use relative dates in the format (now|today)[+-][0-9](day|week|month|year)(s)? (Closes #137) Also fix DateRange not accepting ranges of one day. --- youtube_dl/utils.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'youtube_dl/utils.py') diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 3a2f0022f..6c5b5df4c 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -586,7 +586,29 @@ def unified_strdate(date_str): return upload_date def date_from_str(date_str): - """Return a datetime object from a string in the format YYYYMMDD""" + """ + 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': + return today + match = re.match('(now|today)(?P[+-])(?P