{"id":13411583,"url":"https://github.com/francesconi/go-rampart","last_synced_at":"2026-01-21T02:07:02.049Z","repository":{"id":40250425,"uuid":"479401936","full_name":"francesconi/go-rampart","owner":"francesconi","description":"Determine how intervals relate to each other.","archived":false,"fork":false,"pushed_at":"2024-06-26T14:20:57.000Z","size":27,"stargazers_count":101,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-22T17:03:42.101Z","etag":null,"topics":["date","golang","interval","overlap","time"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/francesconi/go-rampart","language":"Go","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/francesconi.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-08T13:29:42.000Z","updated_at":"2025-08-20T06:37:18.000Z","dependencies_parsed_at":"2024-10-26T07:58:02.721Z","dependency_job_id":"a0d56765-dabe-4fa8-b655-9acc997b4712","html_url":"https://github.com/francesconi/go-rampart","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/francesconi/go-rampart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francesconi%2Fgo-rampart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francesconi%2Fgo-rampart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francesconi%2Fgo-rampart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francesconi%2Fgo-rampart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francesconi","download_url":"https://codeload.github.com/francesconi/go-rampart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francesconi%2Fgo-rampart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28622473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T23:49:58.628Z","status":"online","status_checked_at":"2026-01-21T02:00:08.227Z","response_time":86,"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":["date","golang","interval","overlap","time"],"created_at":"2024-07-30T20:01:14.708Z","updated_at":"2026-01-21T02:07:02.033Z","avatar_url":"https://github.com/francesconi.png","language":"Go","funding_links":[],"categories":["Data Structures and Algorithms","数据结构与算法","Data Integration Frameworks","Generators","Go"],"sub_categories":["Miscellaneous Data Structures and Algorithms","杂项数据结构和算法"],"readme":"# go-rampart\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/francesconi/go-rampart.svg)](https://pkg.go.dev/github.com/francesconi/go-rampart)\n![github.com/francesconi/go-rampart](https://github.com/francesconi/go-rampart/workflows/test/badge.svg)\n[![Codecov](https://codecov.io/gh/francesconi/go-rampart/branch/main/graph/badge.svg?token=Y1G145SZB2)](https://codecov.io/gh/francesconi/go-rampart)\n[![Go Report Card](https://goreportcard.com/badge/github.com/francesconi/go-rampart)](https://goreportcard.com/report/github.com/francesconi/go-rampart)\n\nGo port of the [Haskell Rampart library](https://github.com/tfausak/rampart) by [Taylor Fausak](https://taylor.fausak.me/2020/03/13/relate-intervals-with-rampart).\n\nThis package provides types and functions for defining intervals and determining how they relate to each other. This can be useful to determine if an event happened during a certain time frame, or if two time frames overlap (and if so, how exactly they overlap).\n\n## Install\n\n```sh\ngo get github.com/francesconi/go-rampart\n```\n\n## Examples\n\n### Ordered types\n\nAny type that supports the operators `\u003c` `\u003c=` `\u003e=` `\u003e`.\n\n```go\na := rampart.NewInterval(2, 3)\nb := rampart.NewInterval(3, 7)\nrel := a.Relate(b)\n// rel: RelationMeets\n```\n\n### Any other type\n\n`NewIntervalFunc` accepts any type as long as a comparison function is provided. The comparison function should return values as follows:\n\n```go\ncmp(t1, t2) \u003c 0 if t1 \u003c t2\ncmp(t1, t2) \u003e 0 if t1 \u003e t2\ncmp(t1, t2) == 0 if t1 == t2\n```\n\n#### time.Time\n\n```go\nfunc compareTimes(t1, t2 time.Time) int {\n    return int(t1.Sub(t2))\n}\n\na := rampart.NewIntervalFunc(\n    time.Date(2022, time.April, 1, 0, 0, 0, 0, time.UTC),\n    time.Date(2022, time.April, 8, 0, 0, 0, 0, time.UTC),\n    compareTimes,\n)\nb := rampart.NewIntervalFunc(\n    time.Date(2022, time.April, 6, 0, 0, 0, 0, time.UTC),\n    time.Date(2022, time.April, 15, 0, 0, 0, 0, time.UTC),\n    compareTimes,\n)\nrel := a.Relate(b)\n// rel: RelationOverlaps\n```\n\n![][interval relations]\n\n[interval relations]: ./docs/interval-relations.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancesconi%2Fgo-rampart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancesconi%2Fgo-rampart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancesconi%2Fgo-rampart/lists"}