Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ecmwf/climetlab
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Nov 8, 2020
2 parents 5816e44 + f1c7413 commit 00adf4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions climetlab/utils/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# datetime.fromisoformat() only available from Python3.7
# from backports.datetime_fromisoformat import MonkeyPatch
from dateutil.parser import parse
from re import sub

# MonkeyPatch.patch_fromisoformat()

Expand All @@ -21,6 +22,7 @@ def parse_date(date):
try:
return datetime.datetime.fromisoformat(date)
except Exception:
date = sub(r"Z.*", "", date)
return parse(date)


Expand Down
6 changes: 5 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

from climetlab.core.bbox import BoundingBox
from climetlab.utils import bytes_to_string
from climetlab.utils import bytes_to_string, datetime as dt


def test_bytes():
Expand Down Expand Up @@ -61,3 +61,7 @@ def test_bbox():

bbox = bbox2.merge(bbox1)
assert bbox.width == 60, (bbox1, bbox2, bbox)


def test_parse_date():
dt.parse_date("1851-06-25Z00:00")

0 comments on commit 00adf4a

Please sign in to comment.