The API has a domain-driven design with classes for the different use cases, like LocalDate, ZonedDateTime or Period. For examples LocalDate allows to handle dates like birthdays or holidays in a clean and error-safe way, especially if these dates are persisted to an external server.
js-joda is immutable. Immutability aligns well with pure functions and with the architecture of frameworks like React and Flux.
js-joda is a port of the sophisticated, robust and domain-driven API of Joda-Time (to be more precise of the ThreeTen-Backport of the Java SE 8 java.time package).
The library is in a very early state, far away from productive. But you are very welcome to play around with js-joda and to give your feedback. Please check the tests and the API Documentation for the current state of development.
Install joda using npm
npm install js-joda
Then require it to any module
var LocalDate = require('js-joda').LocalDate; var d = LocalDate.parse('2012-12-24').atStartOfDay().plusMonths(2); // 2013-02-24T00:00:00
To use js-joda from a browser, download either dist/js-joda.min.js or dist/js-joda.js (with sourcemaps for development)
Then add it as a script tag to your page
<script src="js-joda.min.js"></script> <script> var LocalDate = JSJoda.LocalDate; var d = LocalDate.parse('2012-12-24').atStartOfDay().plusMonths(2); // 2013-02-24T00:00:00 </script>
- Cheat Sheet Quick start guide
- API ESDoc generated API documentation hosted by the ESDoc Hosting Service
- js-joda Homepage Project homepage
Our current plan is to have a first milestone with LocalDate, LocalDateTime, Instant, Duration and Period working. The result of the first milestone will be a fully functional Date/Time library, converting from and to ISO8601, with UTC and system default timezone.
Any further timezone converting and localization is not part of the first milestone and will be saved for later. This might also be an extra package to reduce library size if Timezone functionality is not needed.
Joda time is the base for JSR-310 that became part of Java SE 8 in the java.time package. JSR-310 is a new implementation with an API 'inspired by Joda-Time' but improvements on some design flaws (see http://blog.joda.org/2009/11/why-jsr-310-isn-joda-time_4941.html)
js-joda is released under the BSD 3-clause license:
our implementation reference base ThreeTen-Backport (http://www.threeten.org/threetenbp/) is also released under the BSD 3-clause license
Joda-Time is under Apache 2.0 licence.
OpenJDK is under GNU GPL+linking exception.
The author of joda time and the lead architect of the JSR-310 is Stephen Colebourne.