cquiroz / scala-java-time

Implementation of the `java.time` API in scala. Especially useful for scala.js
http://cquiroz.github.io/scala-java-time/
BSD 3-Clause "New" or "Revised" License
126 stars 33 forks source link

Remove java.util.Calendar #87

Closed cquiroz closed 4 years ago

cquiroz commented 6 years ago

scala-java-time contains a half-baked implementation of java.util.Calendar. That class is fairly large and contains many quirks, completing it will be a major task. Instead I propose to remove it, leaving only the static constants. The current implementation contains a minimum of code to support some parts of the code

Inspection of the code reveal this change will involve moving the JapaneseChronology and JapaneseEra classes to be jvm only. At any rate given how broken Calendar is, they likely don't work properly

IMHO we shouldn't ship classes not properly implemented

mdedetrich commented 6 years ago

Can you provide details about what is half baked about it? I made https://github.com/mdedetrich/soda-time some time back which has a part of calendar, although I can't completely remember how hard it was.

Might be something I can look into, the most important is actually having a decent testing suite considering how hard it is to get a correct calendar implementation.

cquiroz commented 6 years ago

If you see the classes: https://github.com/cquiroz/scala-java-time/blob/master/core/js/src/main/scala/java/util/Calendar.scala https://github.com/cquiroz/scala-java-time/blob/master/core/js/src/main/scala/java/util/GregorianCalendar.scala

You'll note many uninmplemented methods and there is a lack of support for non gregorian classes It would be great to have a full implementation but it s a relatively large undertaking

mdedetrich commented 6 years ago

Well I ported JodaTime to Scala in the project I linked earlier, which is what the new Java-Time package was based off. Will have a quick look into it tonight to see how realistic it is

mdedetrich commented 6 years ago

So I had a look at this, it doesn't seem to hard just very laborious process, can probably do it in a week or two.

The only thing that concerns me is testing, although a good suite of property based tests that can test against the JVM javatime should do the trick, is this possible?

cquiroz commented 6 years ago

Sounds great, the test suggestion is exactly what I do, tests run on the jvm and js they validate the implementation

cquiroz commented 6 years ago

Btw, remember we are not allowed to even look at the original jvm code, that’s why tests are very useful as they guide you to the correct implementation beyond what the java doc says

mdedetrich commented 6 years ago

Are you allowed to look at the code for JodaTime?

cquiroz commented 6 years ago

I don’t know, probably yes. What is certainly allowed is Apache harmony, and certainly disallowed is openjdk

cquiroz commented 4 years ago

@mdedetrich Did you have time to look at this?

mdedetrich commented 4 years ago

No unfortunately I have been busy of late (renovating a new place) so I really haven't had time, are you planning a release?

cquiroz commented 4 years ago

I want to do soon a 2.0.0 with the new scala-java-locales and support for scala.js 1.0 I'm waiting for the Scala.js 1.0.1 release though

cquiroz commented 4 years ago

I'm going to make a 2.0.0 release soon and I'll remove Calendar unless we get a revamp

mdedetrich commented 4 years ago

Yeah sorry I don't have the time for this now, maybe for 2.1