Skip to content

Commit

Permalink
Merge pull request #288 from probberechts/fix/opta-timestamps
Browse files Browse the repository at this point in the history
[Opta] Fix F24 timestamp parsing
  • Loading branch information
koenvo authored Jan 22, 2024
2 parents 2ae98d1 + 25021d9 commit 401007a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions kloppy/infra/serializers/event/opta/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@


def _parse_f24_datetime(dt_str: str) -> float:
def zero_pad_milliseconds(timestamp):
parts = timestamp.split(".")
return ".".join(parts[:-1] + ["{:03d}".format(int(parts[-1]))])

dt_str = zero_pad_milliseconds(dt_str)
return (
datetime.strptime(dt_str, "%Y-%m-%dT%H:%M:%S.%f")
.replace(tzinfo=pytz.utc)
Expand Down
1 change: 0 additions & 1 deletion kloppy/tests/test_opta.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def dataset(base_dir) -> EventDataset:
return dataset


@pytest.mark.xfail
def test_parse_f24_datetime():
"""Test if the F24 datetime is correctly parsed"""
# timestamps have millisecond precision
Expand Down

0 comments on commit 401007a

Please sign in to comment.