Skip to content

Conversation

@LouisAuneau
Copy link

@LouisAuneau LouisAuneau commented Dec 5, 2025

Issue

I noticed when converting an ISO 8601 date with a valid timezone, the timezone component is replaced by UTC, which corrupts the actual timestamp.

Reproduction:

from jsonata import Jsonata

expr = Jsonata('$fromMillis($toMillis("2025-01-01T01:00:00+01:00"))')
print(expr.evaluate({}))

You get: 2025-01-01T01:00:00.000Z
While the expected value should be: 2025-01-01T00:00:00.000Z

Proposed solution

Just adding a check to see if the extracted date is timezone aware before using dt.replace(tzinfo=datetime.timezone.utc).

Do not hesitate if you have question or suggestions for some changes. Thank you in advance!


PS: Note none of the tests in jsonata base repository use another timezone than UTC, hence tests couldn't catch this case. I think it would be worth contributing to those tests as well. However the JS implementation does handle timezone changes correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant