Jiffy is a port of Java Time to Clojurescript. As far as possible it aims at being at parity with Java API.
Jiffy is currently work in progress!
Porting the Java Time API to Clojurescript is not done in a jiffy (pun intended). Luckily, Java Time ships as an immutable API, making the job tolerable. Porting the API to Clojurescript should be an exercise in mechanically rewriting Java to Clojurescript, without even the need for you to understand the logic behind the code.
The skeletal structure of the complete API has already been generated from the OpenJDK source code. All the corresponding constructs for Java Time's classes, interface, static methods and fields are already in place and stubbed out.
- For every class file in the Java Time, Jiffy has a corresponding namespace. E.g.
jiffy.instant
corresponds tojava.time.Instant
. - For every interface in Java Time, Jiffy has a corresponding protocol. The name of the protocol is named after the corresponding
Java interface with one tiny exception; Jiffy's protocols are prefixed with the letter 'I', e.g.
ITemporal
(see Differences for rationale) - For every public static methods and fields in Java Time, Jiffy has a corresponding function.
- For every (concrete) class in Java Time, Jiffy has it's corresponding record.
- For every public method in Java Time, Jiffy has it's corresponding function.
What's left is replacing the function bodies with actual working, beautiful Clojurescript code.
- Install Clojure CLI and launch a Clojurescript REPL via
clj -m figwheel.main -b dev -r
- Pick any function in this repository missing an implementation (preferrably in the
jiffy
andjiffy.temporal
namespaces) - Navigate to the corresponding Java implementation by following the link above the function decleration.
- Type corresponding Clojurescript that compiles!
- Repeat steps 1 - 4.
Have a look at the jiffy.instant
namespace. It contains a complete port of the java.time.Instant
.
Yeah, that's rather unfortunate, but your contribution makes is one step closer to have actual running code.
Testing will be accomplished in two parts;
- Porting of Java Time's unit tests
- Generative tests checking parity between Jiffy and Java Time
Feel free to start porting tests, but my main concern at the moment is mechnically porting the Java Time implementation; we won't be able to exercise any base API until the vital parts are in place.