{"id":18646764,"url":"https://github.com/metabase/second-date","last_synced_at":"2025-08-18T19:04:50.832Z","repository":{"id":62433630,"uuid":"255853789","full_name":"metabase/second-date","owner":"metabase","description":"Helpful java.time utility functions for Clojure","archived":false,"fork":false,"pushed_at":"2024-08-30T08:24:16.000Z","size":67,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-13T00:19:59.820Z","etag":null,"topics":["clj-time","clojure","datetime","java-time","temporal"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metabase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-15T08:31:19.000Z","updated_at":"2024-11-15T23:10:56.000Z","dependencies_parsed_at":"2025-04-11T18:11:53.700Z","dependency_job_id":"0a7bd6b1-0fa2-4737-a524-fb3157d7d5c7","html_url":"https://github.com/metabase/second-date","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"3cda9c83f6542e2ea0f46f7b518e00ce267f0795"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/metabase/second-date","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metabase%2Fsecond-date","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metabase%2Fsecond-date/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metabase%2Fsecond-date/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metabase%2Fsecond-date/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metabase","download_url":"https://codeload.github.com/metabase/second-date/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metabase%2Fsecond-date/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270763417,"owners_count":24641022,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["clj-time","clojure","datetime","java-time","temporal"],"created_at":"2024-11-07T06:22:29.485Z","updated_at":"2025-08-18T19:04:50.783Z","avatar_url":"https://github.com/metabase.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/badge/license-Eclipse%20Public%20License-blue.svg?style=for-the-badge)](https://raw.githubusercontent.com/metabase/second-date/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/metabase/second-date?style=for-the-badge)](https://github.com/metabase/second-date/commits/)\n[![cljdoc badge](https://img.shields.io/badge/dynamic/json?color=informational\u0026label=cljdoc\u0026query=results%5B%3F%28%40%5B%22artifact-id%22%5D%20%3D%3D%20%22second-date%22%29%5D.version\u0026url=https%3A%2F%2Fcljdoc.org%2Fapi%2Fsearch%3Fq%3Dmetabase%2Fsecond-date\u0026style=for-the-badge)](https://cljdoc.org/d/metabase/second-date/CURRENT)\n\n[![Clojars Project](https://clojars.org/metabase/second-date/latest-version.svg)](https://clojars.org/metabase/second-date)\n\n![OIG2](https://github.com/metabase/second-date/assets/1455846/db59a1ad-ee86-469b-b96e-2f515f28d06f)\n\n(Thanks Bing Image Creator for this totally accurate portrayal of a Clojure library for working with datetimes that is also a second date)\n\n# Second Date\n\nSecond Date provides a handful of utility functions for working with `java.time`. The most important are:\n\n###### `parse`\n\nCan parse almost any temporal literal String to the correct `java.time` class.\n\n```clj\n(require '[second-date.core :as second-date])\n\n(second-date/parse \"2020-04\")\n;; -\u003e #object[java.time.LocalDate 0x1998e54f \"2020-04-01\"]\n\n(second-date/parse \"2020-04-01\")\n;; -\u003e #object[java.time.LocalDate 0x1998e54f \"2020-04-01\"]\n\n(second-date/parse \"2020-04-01T15:01\")\n;; -\u003e #object[java.time.LocalDateTime 0x121829b7 \"2020-04-01T15:01\"]\n\n(second-date/parse \"2020-04-01T15:01-07:00\")\n;; -\u003e #object[java.time.OffsetDateTime 0x7dc126b0 \"2020-04-01T15:01-07:00\"]\n\n(second-date/parse \"2020-04-01T15:01-07:00[US/Pacific]\")\n;; -\u003e #object[java.time.ZonedDateTime 0x351fb7c8 \"2020-04-01T15:01-07:00[US/Pacific]\"]\n```\n\n`parse` handles ISO-8601 strings as well as SQL literals (e.g. `2020-04-01 15:01:00`).\n\nYou can also use the built-in literal reader `second-date/t`:\n\n```clj\n#second-date/t \"2020-04-01T15:01\"\n;; -\u003e #object[java.time.LocalDateTime 0x121829b7 \"2020-04-01T15:01\"]\n```\n\nFor more convenience, you may want to give this a shorter data reader tag, for example `#t`, in your own project.\n\nOptionally, you can also have Second Date print Temporals in a REPL-friendly format by installing print methods with\n`second-date/install-print-methods!`:\n\n```clj\n#second-date/t \"2020-04-01T15:01\"\n;; -\u003e #object[java.time.LocalDateTime 0x121829b7 \"2020-04-01T15:01\"]\n\n(second-date/install-print-methods!)\n#second-date/t \"2020-04-01T15:01\"\n;; -\u003e #second-date/t \"2020-04-01T15:01\"\n\n;; use a different data reader tag\n(second-date/install-print-methods! 't)\n\n#t \"2020-04-01T15:01\"\n;; -\u003e #t \"2020-04-01T15:01\"\n```\n\n###### `format`\n\nFormats any of the main `java.time` temporal instant classes as a String. Uses ISO-8601 by default, but can use any\n`java.time.format.DateTimeFormatter` or keywords naming static formatters as understood by\n[`clojure.java-time`](https://github.com/dm3/clojure.java-time).\n\n```clj\n(require '[java-time :as t]\n         '[second-date.core :as second-date])\n\n(second-date/format (t/zoned-date-time \"2020-04-01T15:01-07:00[US/Pacific]\"))\n;; -\u003e \"2020-04-01T16:01:00-07:00\"\n\n(second-date/format (t/offset-date-time \"2020-04-01T15:01-07:00\"))\n;; -\u003e \"2020-04-01T16:01:00-07:00\"\n\n(second-date/format (t/local-date-time \"2020-04-01T15:01\"))\n;; -\u003e \"2020-04-01T15:01:00\"\n\n;; with a different formatter\n(second-date/format :basic-iso-date (t/local-date-time \"2020-04-01T15:01\"))\n;; -\u003e  \"20200401\"\n\n;; it even handles Instants\n(second-date/format :iso-week-date (t/instant \"2020-04-01T15:01:00-07:00\"))\n;; \"2020-W14-3Z\"\n```\n\nCheck the value of `java-time.format/predefined-formatters` for all supported predefined formatters.\n\n###### `second-date.parse.builder/formatter`\n\n`second-date.parse.builder/formatter` is a Clojure interface for `java.time.format.DateTimeFormatterBuilder`, used to\ncreate `DateTimeFormatter`s.\n\n```clj\n(require '[java-time :as t]\n         '[second-date :as second-date]\n         '[second-date.parse.builder :as b])\n\n(def my-time-formatter\n  (b/formatter\n   (b/case-insensitive\n    (b/value :hour-of-day 2)\n    (b/optional\n     \":\"\n     (b/value :minute-of-hour 2)\n     (b/optional\n      \":\"\n      (b/value :second-of-minute))))))\n\n;; -\u003e #object[java.time.format.DateTimeFormatter \"ParseCaseSensitive(false)Value(HourOfDay,2)[':'Value(MinuteOfHour,2)[':'Value(SecondOfMinute)]]\"]\n\n;; you can now use the formatter to format and parse\n(second-date/format my-time-formatter (t/zoned-date-time \"2020-04-01T15:23:52.878132-07:00[America/Los_Angeles]\"))\n;; -\u003e \"15:23:52\"\n\n(second-date/parse my-time-formatter \"15:23:52\")\n;; -\u003e #object[java.time.LocalTime 0x514c293c \"15:23:52\"]\n```\n\nSome example formatters can be found in `second-date.parse`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetabase%2Fsecond-date","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetabase%2Fsecond-date","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetabase%2Fsecond-date/lists"}