add dateutil as a dependency, use it in utils.datetime.iso8601_parse
This commit is contained in:
parent
ae7c6d8572
commit
e4d71f6c0c
2 changed files with 5 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
beautifulsoup4==4.8.0
|
||||
cryptography==2.7
|
||||
dataclasses==0.6
|
||||
dateutil==2.8.1
|
||||
dnspython==1.16.0
|
||||
feedparser==5.2.1
|
||||
lxml==4.4.1
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import re, typing
|
||||
import datetime as _datetime
|
||||
|
||||
ISO8601_PARSE = "%Y-%m-%dT%H:%M:%S%z"
|
||||
ISO8601_PARSE_MICROSECONDS = "%Y-%m-%dT%H:%M:%S.%f%z"
|
||||
import dateutil.parser
|
||||
|
||||
ISO8601_FORMAT_DT = "%Y-%m-%dT%H:%M:%S"
|
||||
ISO8601_FORMAT_TZ = "%z"
|
||||
|
@ -27,9 +25,9 @@ def iso8601_format(dt: _datetime.datetime, milliseconds: bool=False) -> str:
|
|||
return "%s%s%s" % (dt_format, ms_format, tz_format)
|
||||
def iso8601_format_now(milliseconds: bool=False) -> str:
|
||||
return iso8601_format(utcnow(), milliseconds=milliseconds)
|
||||
def iso8601_parse(s: str, microseconds: bool=False) -> _datetime.datetime:
|
||||
fmt = ISO8601_PARSE_MICROSECONDS if microseconds else ISO8601_PARSE
|
||||
return _datetime.datetime.strptime(s, fmt)
|
||||
|
||||
def iso8601_parse(s: str) -> _datetime.datetime:
|
||||
return dateutil.parser.isoparse(s)
|
||||
|
||||
def datetime_human(dt: _datetime.datetime):
|
||||
return _datetime.datetime.strftime(dt, DATETIME_HUMAN)
|
||||
|
|
Loading…
Reference in a new issue