Remove java.util.Calendar
cquiroz opened this issue · 13 comments
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
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.
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
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
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?
Sounds great, the test suggestion is exactly what I do, tests run on the jvm and js they validate the implementation
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
Are you allowed to look at the code for JodaTime?
I don’t know, probably yes. What is certainly allowed is Apache harmony, and certainly disallowed is openjdk
@mdedetrich Did you have time to look at this?
No unfortunately I have been busy of late (renovating a new place) so I really haven't had time, are you planning a release?
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
I'm going to make a 2.0.0 release soon and I'll remove Calendar
unless we get a revamp
Yeah sorry I don't have the time for this now, maybe for 2.1