Merge pull request #405 from snan/date-parsing

This commit is contained in:
Daniel Schwarz 2023-09-24 09:18:27 -04:00 committed by GitHub
commit 30857f570d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -122,6 +122,7 @@ def test_timeline(mock_get, monkeypatch, capsys):
'id': '111111111111111111', 'id': '111111111111111111',
'account': { 'account': {
'display_name': 'Frank Zappa 🎸', 'display_name': 'Frank Zappa 🎸',
'last_status_at': '2017-04-12T15:53:18.174Z',
'acct': 'fz' 'acct': 'fz'
}, },
'created_at': '2017-04-12T15:53:18.174Z', 'created_at': '2017-04-12T15:53:18.174Z',
@ -164,6 +165,7 @@ def test_timeline_with_re(mock_get, monkeypatch, capsys):
'created_at': '2017-04-12T15:53:18.174Z', 'created_at': '2017-04-12T15:53:18.174Z',
'account': { 'account': {
'display_name': 'Johnny Cash', 'display_name': 'Johnny Cash',
'last_status_at': '2011-04-12',
'acct': 'jc' 'acct': 'jc'
}, },
'content': "<p>The computer can&apos;t tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows.</p>", 'content': "<p>The computer can&apos;t tell you the emotional story. It can give you the exact mathematical design, but what's missing is the eyebrows.</p>",

View file

@ -394,7 +394,7 @@ def _convert(field_type, value):
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z") return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")
if field_type == date: if field_type == date:
return date.fromisoformat(value) return datetime.fromisoformat(value.replace('Z', '+00:00')).date()
if get_origin(field_type) == list: if get_origin(field_type) == list:
(inner_type,) = get_args(field_type) (inner_type,) = get_args(field_type)