mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-22 16:44:32 +01:00
handle wrong formatted date argument
The provided date argument (--date, --datebefore or --dateafter) is parsed by datetimp.strptime(). This function throws as ValueError exception at failure. This patch implements exception handling by catching the ValueError exception, printing an error message and exiting with a non-zero exit code.
This commit is contained in:
parent
504f20dd30
commit
4d64bc5251
@ -1270,7 +1270,10 @@ def date_from_str(date_str):
|
||||
unit += 's'
|
||||
delta = datetime.timedelta(**{unit: time})
|
||||
return today + delta
|
||||
return datetime.datetime.strptime(date_str, '%Y%m%d').date()
|
||||
try:
|
||||
return datetime.datetime.strptime(date_str, '%Y%m%d').date()
|
||||
except ValueError:
|
||||
sys.exit('ERROR: cannot parse datestring ' + date_str)
|
||||
|
||||
|
||||
def hyphenate_date(date_str):
|
||||
|
Loading…
Reference in New Issue
Block a user