Skip to content

Commit

Permalink
Merge pull request #405 from snan/date-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
danschwarz authored Sep 24, 2023
2 parents f6e4549 + b344bb3 commit 30857f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def test_timeline(mock_get, monkeypatch, capsys):
'id': '111111111111111111',
'account': {
'display_name': 'Frank Zappa 🎸',
'last_status_at': '2017-04-12T15:53:18.174Z',
'acct': 'fz'
},
'created_at': '2017-04-12T15:53:18.174Z',
Expand Down Expand Up @@ -164,6 +165,7 @@ def test_timeline_with_re(mock_get, monkeypatch, capsys):
'created_at': '2017-04-12T15:53:18.174Z',
'account': {
'display_name': 'Johnny Cash',
'last_status_at': '2011-04-12',
'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>",
Expand Down
2 changes: 1 addition & 1 deletion toot/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def _convert(field_type, value):
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")

if field_type == date:
return date.fromisoformat(value)
return datetime.fromisoformat(value.replace('Z', '+00:00')).date()

if get_origin(field_type) == list:
(inner_type,) = get_args(field_type)
Expand Down

0 comments on commit 30857f5

Please sign in to comment.