-
Couldn't load subscription status.
- Fork 1.4k
Improve the precision of ClockLive#currentTime
#9963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the precision of ClockLive#currentTime
#9963
Conversation
| 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 | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
/fixes #9960