{"id":22903982,"url":"https://github.com/json2d/timecoach","last_synced_at":"2025-10-10T22:03:20.135Z","repository":{"id":57475532,"uuid":"237090752","full_name":"json2d/timecoach","owner":"json2d","description":"a utility library for generating chunks of time within a datetime range","archived":false,"fork":false,"pushed_at":"2020-02-07T03:47:13.000Z","size":11,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-27T04:34:10.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.org/project/timecoach/","language":"Python","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/json2d.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}},"created_at":"2020-01-29T21:59:29.000Z","updated_at":"2024-02-05T22:12:11.000Z","dependencies_parsed_at":"2022-09-07T13:51:12.986Z","dependency_job_id":null,"html_url":"https://github.com/json2d/timecoach","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/json2d/timecoach","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Ftimecoach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Ftimecoach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Ftimecoach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Ftimecoach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/json2d","download_url":"https://codeload.github.com/json2d/timecoach/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Ftimecoach/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005460,"owners_count":26083898,"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-10-10T02:00:06.843Z","response_time":62,"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":[],"created_at":"2024-12-14T02:39:40.321Z","updated_at":"2025-10-10T22:03:20.103Z","avatar_url":"https://github.com/json2d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⏳ timecoach\na utility library for generating chunks of **time** within a datetime range\n\n## Installation\n\n```bash\npip install timecoach\n```\n\n## Quick Start\n\nhere's how to iterate through chunks of **iso hours** using `timecoach.chunk_hours`:\n\n```py\nimport timecoach\nimport datetime\n\nstart = datetime.datetime(2020, 1, 11, 12, 30, 0) # 12:30pm on January 11th 2020\nend = datetime.timedelta(hours=2) # two hours later\n\nfor chunk_start, chunk_end in timecoach.chunk_hours(start, end)\n  diff = chunk_end - chunk_start\n  print(\"i'm a {} minute time chunk!\".format(diff.minutes))\n\n# i'm a 30 minute time chunk!\n# i'm a 60 minute time chunk!\n# i'm a 30 minute time chunk!\n```\n\nand other common chunk sizes:\n\n```py\ntimecoach.chunk_seconds(start, end) \ntimecoach.chunk_minutes(start, end) \ntimecoach.chunk_hours(start, end)\ntimecoach.chunk_days(start, end)\ntimecoach.chunk_months(start, end)\ntimecoach.chunk_years(start, end)\n```\n\nto specify a custom chunk size:\n\n```py\ntimecoach.chunk(start, end, minutes=15) # quarter hours \ntimecoach.chunk(start, end, hours=12) # half days \ntimecoach.chunk(start, end, months=3) # quarter years\n```\n\nthere are a few caveat with custom chunk sizes:\n- the chunk interval must be divisible by its parent interval\n- the chunk interval must be defined with a single interval type \n- the chunk interval value must be a non-zero positive integer\n\nfor example the following would throw exceptions:\n\n```py\ntimecoach.chunk(start, end, minutes=13)\n# AssertionError:  13 minutes is not divisible by parent interval 1 hours (60 minutes)\n\ntimecoach.chunk(start, end, hours=1, minutes=15)\n# AssertionError: 1 hours 15 minutes does not contain only one interval type\n\ntimecoach.chunk(start, end, hour=.25)\n# AssertionError: .25 hours is not non-zero positive integer interval value\n\ntimecoach.chunk(start, end, hour=-1)\n# AssertionError: .25 hours is not non-zero positive integer interval value\n\n```\n\nif your chunk interval type is `year` then sky's the limit since its the highest interval:\n\n```py\ntimecoach.chunk(start_of_time, now, years=1000000) # every million years since the start of time\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson2d%2Ftimecoach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjson2d%2Ftimecoach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson2d%2Ftimecoach/lists"}