Skip to content

Conversation

@keynmol
Copy link

@keynmol keynmol commented Nov 6, 2024

Closes #518

It seems that this used to work, but relied on the fact that ZoneOffset.UTC will put "Z" in
ID_CACHE when object is initialised.

This no longer works because ZoneOffset.UTC was made into a lazy val, so invoking ZoneOffset.of("Z") will not trigger the ZoneOffset.UTC calculation.

To confirm, just touching ZoneOffset.UTC is enough to make repro work:

scala-cli -e 'java.time.ZoneOffset.UTC;java.time.ZoneOffset.of("Z")' --js --dep io.github.cquiroz::scala-java-time::2.6.0 # succeeds

I feel like relying on this cache behaviour is too brittle, so I decided to explictly special-case "Z" as it's a special case in java docs as well.


Note that this case is already tested, but one of the previous tests refers to ZoneOffset.UTC, triggering the cache update.

Copy link
Owner

@cquiroz cquiroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@cquiroz cquiroz merged commit 3f25107 into cquiroz:master Nov 6, 2024
11 checks passed
@keynmol keynmol deleted the special-case-Z-ZoneOffset branch November 6, 2024 11:18
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.

ZoneOffset.of("Z") behaviour differs from JVM

2 participants