The path from 0.3.x version to 0.4.0 has some rough edges due to some small changes in the public API.

AST Changes

Cron4s 0.4.0 comes (finally) with support for using ? symbols in the day of month and day of week fields. This also means that the ast node that represents those fields has a type that is different from other ones. This prevents the programmatically creation of cron expressions using that symbol in fields where it is illegal.

The bad thing is that code that this breaks the binary compatibility of between 0.4.0 and previous 0.3.x and code that was accessing the fields themselves will need to be re-compiled.

Breaking API Changes

These are the most notable changes in Cron4s that will require users to update their code to be able to use this version.

Node Step Semantic Changes

The semantics of the operations step, next and prev have slightly changed their semantics in 0.4.0. The key difference will be observed when the result of stepping over a field does not alter the field value; in such a case the step and related methods will return a None, meaning that there was no valid result.

JSR-310 Unification

Support for JSR-310 (the Java Time API), which was split between the packages cron4s.lib.javatime in the JVM and the package cron4s.lib.threetenbp in ScalaJS, has been unified in both platforms using the former package name. That means that ScalaJS code that was using the JSR-310 backport should change now to cron4s.lib.javatime and everything should work the same way.

Note: JSR-310 support in ScalaJS is not yet final but it’s mature enough to be used. This change removes the burden of dealing with two separate namespaces for the same APIs.

Joda Time Module

Joda Time is support is no longer included in the core module, it has been moved to the cron4s-joda module. To continue using it you must include this last module among your dependencies:

libraryDependencies += "com.github.alonsodomin.cron4s" %% "cron4s-joda" % "0.6.1"

Field access from expressions

The generic field access method named field has changed its signature. The change comes motivated by the new AST node and basically because in the previous version there was some awful runtime casting going on. The old and new signatures are as follows:

Old signature:

def field[F <: CronField](implicit unit: CronUnit[F]): Option[FieldNode[F]]

New signature:

def field[F <: CronField](implicit selector: FieldSelector[CronExpr, F]): selector.Out[F]

The new signature looks more complex than the previous one and sort of returns a magic type out of that implicit selector. However it comes with a big benefit:

The return type is now calculated at compile time and will return the right type for the given field or the code won’t compile. No need to work with the resulting Option anymore.

Scalaz VS Cats

Previous versions of cron4s were using Scalaz internally as a foundation for some of the common abstractions used to implement the core functionality. In 0.4.0 Scalaz has been replaced by Cats for exactly the same purpise. Cats is more lightweight than Scalaz and provides better integration with the Scala standard library.