circe / not-java-time   0.2.0

Apache License 2.0 GitHub

Not a java.time implementation

Scala versions: 2.13 2.12 2.11
Scala.js versions: 0.6

not-java-time

Build status Gitter Maven Central

Update

The circe 0.12.x releases no longer require a java.time implementation on Scala.js, and this is unlikely to change in future releases.

I'll continue to maintain this library as a public service, and will happily accept pull requests supporting additional parts of the API from anyone who needs them. You can still use this library with circe 0.12.x or later releases, and the runtime exceptions it throws if you accidentally use the java.time codecs (scala.NotImplementedError: Get a real java.time) are at least arguably a little more helpful than the runtime linking errors you'd get without it.

Wtf is this

This project is a mostly unimplemented java.time implementation.

Why does it exist

java.time is a relatively not terrible library for working with dates and times that ships with Java 8 and is therefore available to users of modern Scala versions on the JVM. Some Scala libraries, like circe, refer to java.time classes, which is great for people working on the JVM, but not for people using Scala.js, which does not provide an implementation of java.time off the shelf.

Fortunately for Scala.js users who want to work with java.time (and libraries that depend on it), there's at least one solid, actively maintained implementation that can be pulled in as an extra dependency. You'd add something like this to your build:

.jsSettings(
  libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.0.0-RC3"
)

…and you get a fully-functional Scala.js implementation of java.time.

Unfortunately scala-java-time is huge, because a correct java.time implementation needs a bunch of time zone stuff, etc. The size can be a problem for Scala.js applications.

The not-java-time library provides the most minimal implementation of a java.time package that avoids linking errors for Scala.js users of circe (and possibly other libraries in the future). You add this to your build:

.jsSettings(
  libraryDependencies += "io.circe" %%% "not-java-time" % "0.2.0"
)

…and your circe-using Scala.js project will compile without linking errors. If you try to use any of the java.time encoders or decoders, you'll get a runtime error.

Why don't you just make these instances JVM-only in circe

Because I kind of hate Scala.js and refuse to let it make more of a mess of my projects than it already has and also I'm stubborn.

License

not-java-time is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.