Open marcadella opened 3 years ago
I guess it is because, contrary to what the doc says, the default system timezone is used by default instead of UTC. If it is not what the doc mean, then it should be fixed to specify that one need to use UTC explicitly. Ex: LocalDateTime.now(ZoneId.of("UTC))
works in ScalaJs.
I think you're right. it will try to guess the local timezone, it is better to set a default one. PRs to the documentation are welcome
I came to this issue because I started to get this exception after upgrading from udash-0.8.0 to udash-0.9.0.
Udash used https://github.com/zoepepper/scalajs-jsjoda in previous versions. I am not sure what its implementation of LocalDateTime.now
was, but it did not throw any exceptions. Most likely it just calls ZoneId.systemDefault()
from JS Joda.
it is better to set a default one.
When I am using this in a frontend (browser), what way can I use to set the default timezone to something reasonable? I do not want users to have to tell me their timezone, there surely must by some simpler way.
The code tries to guess the timezone but it is not always successful https://github.com/cquiroz/scala-java-time/blob/master/core/js/src/main/scala/java/util/TimeZone.scala#L28
I'd suggest you try to verify what is being selected with that piece of code.
The following code works in scala:
LocalDateTime.now()
. But in Scalajs it throws:java.time.zone.ZoneRulesException: Unknown time-zone ID: Europe/Oslo
. I do not intend to use any timezone. Scalajs version: 1.5.0 scala-java-time version: 2.1.0