{"id":26956280,"url":"https://github.com/quoll/qtime","last_synced_at":"2025-04-03T03:20:56.979Z","repository":{"id":283742186,"uuid":"952777728","full_name":"quoll/qtime","owner":"quoll","description":"Wrapper around Java Time","archived":false,"fork":false,"pushed_at":"2025-03-24T13:02:40.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T19:49:09.158Z","etag":null,"topics":["clojure","time"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quoll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-03-21T21:36:17.000Z","updated_at":"2025-03-24T13:02:44.000Z","dependencies_parsed_at":"2025-03-21T22:38:35.656Z","dependency_job_id":null,"html_url":"https://github.com/quoll/qtime","commit_stats":null,"previous_names":["quoll/qtime"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quoll%2Fqtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quoll%2Fqtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quoll%2Fqtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quoll%2Fqtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quoll","download_url":"https://codeload.github.com/quoll/qtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246928325,"owners_count":20856274,"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","time"],"created_at":"2025-04-03T03:20:56.343Z","updated_at":"2025-04-03T03:20:56.957Z","avatar_url":"https://github.com/quoll.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QTime\n## A java.time wrapper\n\u003cimg src=\"https://github.com/user-attachments/assets/a6c53fc2-77d7-4213-b32d-c7af51beb46c\" alt=\"The Persistence of Memory\" width=\"375\" height=\"285\" align=\"right\"\u003e\u003c/img\u003e\n\nThis is a small library for time operations, based on [`java.time`](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/time/package-summary.html).\n\nIt works with timestamps in UTC and durations, converting appropriately whenever possible. It is aware of other time objects, such as Joda Time, `java.util.Date`, string representations, and milliseconds since the Epoch, and will convert them to `java.time` objects whenever possible.\n\nIt also provides wrappers for each of the member functions around timestamps and durations, allowing for easier interoperability with the rest of the `java.time.*` packages.\n\nThe original Java time objects, such as `java.util.Date` and `java.util.Calendar`, were minimal and proved to be inadequate, leading to the open-source [Joda Time](https://www.joda.org/joda-time/) library. This was the foundation of [JSR-310](https://jcp.org/en/jsr/detail?id=310), which brought a fully capable time library into Java.\n\nConsequently, these other libraries are deprecated, but are still in common use. QTime provides a simple way to use the new `java.time` library while still being able to work with these older libraries. QTime will convert other time formats into `java.time` objects though exporting is not handled. Exporting should typically be done by exporting milliseconds-since-the-Epoch, which can be handled by most libraries.\n\nThis library is opinionated, in that it typically works with UTC, though there is some concession to other timezones.\n\n## Timestamps\nMoments in time are described by the Java interface `java.time.Temporal`. Timestamps are handled by the `java.util.Instant` class, which implements `Temporal`, and are the main temporal object used by QTime.\n\nMost common timestamps can be used in any function that expects a `Temporal` object, and QTime will convert it to an `Instant` whenever possible.\n- `java.util.Date`\n- `org.joda.time.ReadableDateTime`\n- `String` - in ISO-8601 format\n- `long` - milliseconds since the Unix Epoch (1970-01-01T00:00:00Z)\n\n## Durations\nPeriods of time are described by the Java interface `java.time.TemporalAmount`. These are managed in QTime by the `java.time.Duration` class.\n\nThe main other implementation of `TemporalAmount` is `java.time.Period`. This is very similar to `Duration`, but automatically handles infrequent adjustments, such as leap years. When using QTime, `Periods` are converted into `Duration`. Long values are converted into `Duration` as milliseconds.\n\n## Conversions\nCompatible types will always be converted appropriately into `Instant` or `Duration`. These include `java.util.Date` and objects from Joda Time.\n\nInstants are all compatible with ISO-8601 strings. They can be emitted as strings in UTC, or with a timezone, using the `iso-str` function.\n\nThe `Instant` and `Duration` functions are all wrapped, with automatic conversions.\nReferences to time units may be made with strings, keywords, or Java objects.\ne.g. \\\"sec\\\" for seconds, :ms for milliseconds, java.time.temporal.ChronoUnit/NANOS for nanoseconds.\n\nThis allows function calls like:\n```clojure\n(until \"2025-03-22T21:53:26Z\" \"2025-12-25T00:00:00Z\" :days) ;; whole days until Christmas\n(get-long (now) :day-of-year) ;; what day of the year is it?\"\n```\n\n## TODO\nTesting. There is so much testing to be done. The basics work though.\n\n`ZonedDateTime` has a lot of functions that will be useful to wrap and expose. I also want to create factory functions to make it easier to do things like:\n```clojure\n(-\u003e (between (now) (date 2025 :dec 25)) to-days)\n```\nRight now, this needs: `(-\u003e (between (now) (LocalDate/of 2025 12 25)) to-days)`\n\nDocumentation.\n\n## License\n\nCopyright © 2023-2025 Paula Gearon\n\nDistributed under the Eclipse Public License version 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquoll%2Fqtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquoll%2Fqtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquoll%2Fqtime/lists"}