Skip to content

Commit

Permalink
chore: fix datetime parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Feb 26, 2024
1 parent a4d5fcc commit b40b669
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion playwright/_impl/_js_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def parse_value(value: Any, refs: Optional[Dict[int, Any]] = None) -> Any:
return a

if "d" in value:
return datetime.fromisoformat(value["d"][:-1])
return datetime.fromisoformat(value["d"])

if "o" in value:
o: Dict = {}
Expand Down
6 changes: 3 additions & 3 deletions tests/async/test_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ async def test_evaluate_evaluate_date(page: Page) -> None:
result = await page.evaluate(
'() => ({ date: new Date("2020-05-27T01:31:38.506Z") })'
)
assert result == {"date": datetime.fromisoformat("2020-05-27T01:31:38.506")}
assert result == {"date": datetime.fromisoformat("2020-05-27T01:31:38.506Z")}


async def test_evaluate_roundtrip_date(page: Page) -> None:
date = datetime.fromisoformat("2020-05-27T01:31:38.506")
date = datetime.fromisoformat("2020-05-27T01:31:38.506Z")
result = await page.evaluate("date => date", date)
assert result == date


async def test_evaluate_jsonvalue_date(page: Page) -> None:
date = datetime.fromisoformat("2020-05-27T01:31:38.506")
date = datetime.fromisoformat("2020-05-27T01:31:38.506Z")
result = await page.evaluate(
'() => ({ date: new Date("2020-05-27T01:31:38.506Z") })'
)
Expand Down

0 comments on commit b40b669

Please sign in to comment.