◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
8 changes: 4 additions & 4 deletions Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def fromisoformat(cls, date_string):
assert len(date_string) == 10
return cls(*_parse_isoformat_date(date_string))
except Exception:
raise ValueError('Invalid isoformat string: %s' % date_string)


# Conversions to string
Expand Down Expand Up @@ -1369,7 +1369,7 @@ def fromisoformat(cls, time_string):
try:
return cls(*_parse_isoformat_time(time_string))
except Exception:
raise ValueError('Invalid isoformat string: %s' % time_string)


def strftime(self, fmt):
Expand Down Expand Up @@ -1646,13 +1646,13 @@ def fromisoformat(cls, date_string):
try:
date_components = _parse_isoformat_date(dstr)
except ValueError:
raise ValueError('Invalid isoformat string: %s' % date_string)

if tstr:
try:
time_components = _parse_isoformat_time(tstr)
except ValueError:
raise ValueError('Invalid isoformat string: %s' % date_string)
else:
time_components = [0, 0, 0, 0, None]

Expand Down
9 changes: 9 additions & 0 deletions Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import os
import pickle
import random
import struct
import unittest

Expand Down @@ -2676,6 +2677,14 @@ def test_fromisoformat_fails_datetime(self):
with self.assertRaises(ValueError):
self.theclass.fromisoformat(bad_str)

def test_fromisoformat_utc(self):
dt_str = '2014-04-19T13:21:13+00:00'
dt = self.theclass.fromisoformat(dt_str)
Expand Down
Loading
Toggle all file notes Toggle all file annotations