{"id":27483524,"url":"https://github.com/henryw374/cljc.java-time","last_synced_at":"2025-05-15T11:08:02.403Z","repository":{"id":55382219,"uuid":"180191251","full_name":"henryw374/cljc.java-time","owner":"henryw374","description":"java.time clojure clojurescript","archived":false,"fork":false,"pushed_at":"2025-03-18T09:10:22.000Z","size":952,"stargazers_count":136,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-14T04:43:51.821Z","etag":null,"topics":["clojure","clojurescript","java","javascript"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henryw374.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":"widdindustries","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-04-08T16:38:48.000Z","updated_at":"2025-05-13T16:02:34.000Z","dependencies_parsed_at":"2025-04-16T16:17:15.099Z","dependency_job_id":"99689044-46b8-49c3-a5fc-fafd1c2c412e","html_url":"https://github.com/henryw374/cljc.java-time","commit_stats":{"total_commits":89,"total_committers":8,"mean_commits":11.125,"dds":0.101123595505618,"last_synced_commit":"64804a4f5885e38ac8a1050f727ef6781239225d"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryw374%2Fcljc.java-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryw374%2Fcljc.java-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryw374%2Fcljc.java-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henryw374%2Fcljc.java-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henryw374","download_url":"https://codeload.github.com/henryw374/cljc.java-time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110377,"owners_count":22016391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","clojurescript","java","javascript"],"created_at":"2025-04-16T15:49:43.663Z","updated_at":"2025-05-15T11:08:02.366Z","avatar_url":"https://github.com/henryw374.png","language":"Clojure","readme":"[![Clojars Project](https://img.shields.io/clojars/v/com.widdindustries/cljc.java-time.svg)](https://clojars.org/com.widdindustries/cljc.java-time)\n[![Tests build](https://github.com/henryw374/cljc.java-time/actions/workflows/tests.yaml/badge.svg)](https://github.com/henryw374/cljc.java-time/actions/workflows/tests.yaml)\n[![bb compatible](https://raw.githubusercontent.com/babashka/babashka/master/logo/badge.svg)](https://book.babashka.org#badges)\n\n# cljc.java-time\n\nA Clojure(Script) library which mirrors the java.time api through kebab-case-named vars.\n\nThe java.time api is augmented with:\n* predicate functions for each entity type: `(cljc.java-time.extn.predicates/instant? x)`\n* more helpful error messages for unsupported operations on Instants \n\nThis library uses a pure-JS implementation of java.time, see here [for discussion on whether that affects application performance or build size](https://widdindustries.com/clojurescript-datetime-lib-comparison/)\n\nSee [my talk at Clojure/North 2019](https://www.youtube.com/watch?v=UFuL-ZDoB2U) for more background.\n\nTemporal, the [new JS platform Date-Time lib](https://github.com/tc39/proposal-temporal)\nhas been considered for use as an alternative basis of this library instead of js-joda, but although it has\nsome overlap with java.time, Temporal is different enough that implementing cljc.java-time would be very \ndifficult. For a dependency-free Clojure(Script) date-time API, see [Tempo](https://github.com/henryw374/tempo)\n\n\n## Related Libraries\n\n[tick](https://clojars.org/tick) is a higher level date-time library that uses this one. Even if you're using cljc.java-time directly,\nie not through tick, it has very relevant docs on extra [setup for use with ClojureScript](https://github.com/juxt/tick/blob/master/docs/cljs.adoc)\n\n[time-literals](https://github.com/henryw374/time-literals) is a Clojure(Script) library which provides tagged literals for objects from jsr-310 domain \n\n## Rationale\n\nThis library sits atop `java.time` on the jvm and [cljs.java-time](https://github.com/henryw374/cljs.java-time) on Javascript\nplatforms. Writing cross-platform code that uses those libraries directly is harder than interop normally is because:\n\n* To call the java.time 'static' methods in a cljc file you need to use the [dot-special-form](https://clojure.org/reference/java_interop#_the_dot_special_form) which is not idiomatic\n* The underlying js library has changed the name of the getter methods in java.time (in *almost* all cases)  to remove the 'get' part of the name. There are ways to get around that on a case\nby case basis, but this library handles it for you.\n\n### .. but I just develop on the JVM Only\n\nReasons to use this:\n\n* All type hinting is done for you\n* `comp`, `apply`, `juxt` and all other clojure.core fns that apply to fns can now be used without anon fns: `#(.foo %)`\n* In fact, instead of seeing `#(.foo %)` in someone's code and not knowing what foo is, you'll have a properly namespaced clojure function `foo` - much better!\n* predicates, for example `(local-date? x)` \n \n## How it works\n\nFor every class in java.time, there is a clojure namespace. \n\nFor example, corresponding to `java.time.LocalDate`, there is a namespace\n\n`cljc.java-time.local-date`\n\nIn that and every other namespace, there is one var per public method/field in the corresponding class.\n\nFor example, for the method `java.time.LocalDate/parse`, there is a corresponding function `cljc.java-time.local-date/parse`\n\nInstance methods take the instance as the extra first arg\n\n## Usage\n\nClojars badge is at the top of this README\n\nVersion 0.1.9 and up require minimum Clojurescript version of 1.10.741\n\nIf using cljsjs, add [js-joda](https://clojars.org/henryw374/js-joda) and [js-joda-locale-en-us](https://clojars.org/henryw374/js-joda-locale-en-us) to your dependencies as well\n\nIn .cljc file\n```clj\n(ns my.cljc\n  (:require  [cljc.java-time.local-date :as ld])\n   \n;create a date\n(def a-date (ld/parse \"2019-01-01\"))\n   \n;add some days\n(ld/plus-days a-date 99)\n```\n\nRoundtripping with legacy Date\n```clj \n\n(require '[cljc.java-time.instant :as i])\n\n;cljs\n(-\u003e (js/Date.) (.getTime) (i/of-epoch-milli) (i/to-epoch-milli) (js/Date.))\n\n;clj \n(-\u003e (Date.) (.getTime) (i/of-epoch-milli) (i/to-epoch-milli) (Date.))\n\n```\n\nHere is how to get to a babashka (v 1.2.174+) repl with cljc.java-time:\n\n```\nexport BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {com.widdindustries/cljc.java-time {:mvn/version \"RELEASE\"}}}')\n\nbb\n```\n\n \n## Problems \u0026 Irregularities\n\njava.time.Year#isLeap exists as an instance method and a static method. Only the static version has been wrapped.\n\n### Inheritance/Polymorphism \nThe code of this project consists of mechanically generated functions for the java.time methods, even if those methods are \ninherited via superclasses or interfaces. In this project, functions are generated in every class they can be applied to. For example there is\n`cljc.java-time.temporal.temporal/is-supported` and also `cljc.java-time.local-date/is-supported`, with the latter being \nessentially unnecessary but included anyway. \n \n\n## Note\n \n### Java 9 \n\nA couple of new methods were added to `java.time` in Java 9 - these are not included in this library because according\nto the [Clojure Survey](https://clojure.org/news/2020/02/20/state-of-clojure-2020) about half\nof Clojure users are still on Java 8 :(\n \n### ClojureScript\n\nBe aware that the underlying js implementation is probably only 99% complete. Anything you find missing can be added via pull\nrequest to [js-joda](https://github.com/js-joda/js-joda)\n\n## Development\n\nThe code of the project is generated by the `generate-library-code!` function in the \ndev/gen.clj namespace.\n\n### Clojure and Clojurescript \n\nTo run all tests:\n\n```\nmake test \n```\n\nStart a repl: \n\n```\n clj -Adev:test:test-cljs\n```\n\nFor Clojurescript dev, see the dev/cljs.clj file for functions to start test build\nin shadow and run tests.\n\n### babashka\n\nStart babashka as follows\n\n```\ndeps -A:test -Scommand \"bb -cp {{classpath}}\" --socket-repl 1666'\n```\n\nand run tests from the repl\n\none cmd to do this would be preferable\n \n## License\n\nCopyright © 2021 [Widd Industries](http://widdindustries.com/about/)\n\nDistributed under the [MIT License](/LICENSE)\n","funding_links":["https://patreon.com/widdindustries"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryw374%2Fcljc.java-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenryw374%2Fcljc.java-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenryw374%2Fcljc.java-time/lists"}