Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kyri-petrou
Copy link
Contributor

@kyri-petrou kyri-petrou commented Jun 11, 2025

/fixes #9960

@kyri-petrou kyri-petrou requested a review from hearnadam June 11, 2025 13:34
@kyri-petrou kyri-petrou enabled auto-merge (squash) June 11, 2025 13:34
hearnadam
hearnadam previously approved these changes Jun 11, 2025
Comment on lines 246 to 255
private def toChronoUnit(unit: TimeUnit): ChronoUnit =
(unit: @switch) match {
case TimeUnit.NANOSECONDS => ChronoUnit.NANOS
case TimeUnit.MICROSECONDS => ChronoUnit.MICROS
case TimeUnit.MILLISECONDS => ChronoUnit.MILLIS
case TimeUnit.SECONDS => ChronoUnit.SECONDS
case TimeUnit.MINUTES => ChronoUnit.MINUTES
case TimeUnit.HOURS => ChronoUnit.HOURS
case TimeUnit.DAYS => ChronoUnit.DAYS
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hearnadam the toChronoUnit isn't implemented in JS / Native (I'm guessing it's because it was added in JDK9) so I added a method to manually map it. The implementation is the same as in the java library

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Egh... Annoyingly @switch doesn't work with java enums in Scala 🤦

We can either leave it as a non-switch statement or implement it separately for JS / Native. WDUT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, that makes sense. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went with a platform-specific syntax, since the method already exists on the JVM it didn't make sense to re-implement it

@kyri-petrou kyri-petrou disabled auto-merge June 11, 2025 14:33
@hearnadam hearnadam merged commit a47c6f1 into zio:series/2.x Jun 11, 2025
19 checks passed
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.

ClockLive#UnsafeAPI.currentTime should use ChronoUnit for conversion

2 participants