-
Notifications
You must be signed in to change notification settings - Fork 384
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
java.time.* from Java 1.8 is missing #1618
Comments
This requires a huge amount of work to port a BSD- or MIT-licensed implementation of those to Scala. The core team doesn't have the manpower to work on this, but PRs are welcome! |
Thanks for looking and keeping it open; I didn't expect an overnight solution to this. But I have an idea / doubt: Is it possible to provide parts of the Java standard library as a separate Scala JS library? Will that help with the license restriction? (I am assuming there is some automated way to translate existing Java code / Java-byte-code to a Scala-JS compatible library). |
Oh yes, you can certainly provide parts of the JDK as separate Scala.js libraries. You just have to configure the build not to bundle the There is no automated way to translate Java to Scala.js per se. I know there are a few Java-to-Scala converters out there, but they are known to be imperfect at best. If the Scala code does not depend on other non-supported parts of the library, then they should work with Scala.js out-of-the-box. |
@hrj you might be better of writing a scalajs interface to something like http://momentjs.com/ (or using it adhoc as |
@rparree Thanks for the suggestion, but no, I want to share this code on server and client sides, so that I can be sure they are computing the same results, among other reasons. |
Gotcha..i am in the same situation. At this point i am using JSR 310 on the server and momentjs (via some partial traits) on the client (so had to make different case classes for client and server for this feature) |
Joda-Time has an Apache license. Since Apache Harmony has a compatible license, does Joda-Time? |
Yes. Joda-Time would have a compatible license. But since it would probably be best to port it in a separate project anyway, this would not really matter. |
Maybe I misunderstood, but a separate project wouldn't help people using java.time — right? |
No. But someone could implement Joda-Time in a separate project. This would also allow people that still use JDK{6|7} to use it. |
Wait what? People who still use JDK{6|7} can just use Joda-Time directly. Plus, this ticket is about |
As a side note, I am currently working on porting I used http://javatoscala.com/, but its definitely far from perfect, and a lot of code I have had to manually alter/rewrite. Also, there are a lot of constructs that Java has, which Scala doesn't have, which include
And Regarding |
@mdedetrich Just a quick note: The Scala.js optimizer will inline We can't port |
@gzm0 Thanks for the heads up! Also regard Note that I am not a lawyer, but even if you do use converters, none of them will produce 100% correct Scala, so you will always end up heavily altering any converted code |
Clean room implementations are fine, of course. That's what we do all the time. Even if you rework the code produced by a converter, it's not a clean room implementation, though. So yes it's a lot of work. |
Cool thanks for letting me know |
Hey guys, just letting you know that I have done an early release of |
Nobody seems to have mentioned it, but maybe some of you guys know about it: most of the code from jsr310 is actually BSD licensed, it was GPLed after a lot of initial work for its inclusion into the openjdk. I guess the original BSD code can still be found, but what can be of special interest for people who want to take a stab at a Scala.js implementation is that the author of the joda time library took the original BSD code and created a backport for jdk6-7: https://github.com/ThreeTen/threetenbp. Also, by doing a very quick comparison, it seems the GPL code in openjdk is very close to the backport code, so there actually exists a good and robust BSD licensed java lib which implements parts of the jsr. I am no expert in licenses but I think it is compatible with Scala.js, maybe someone can confirm that. If this is the case, then it could help people who want to make or review PRs on this issue. For example I see that @ummels did not implement |
This is now addressed in a separate repo: See also #2039 for an alternative implementation, which is still worth discussing. |
Anyone stumbling across this, scala-java-time currently seems to be one of the more compelling options. https://github.com/cquiroz/scala-java-time |
Java 8 has number of convenient Date & Time classes modelled on Joda Time. Would be great to be supported in Scala-JS.
Examples:
The text was updated successfully, but these errors were encountered: