{"id":19349147,"url":"https://github.com/bartmika/timekit","last_synced_at":"2025-04-23T06:30:50.113Z","repository":{"id":39878225,"uuid":"446222305","full_name":"bartmika/timekit","owner":"bartmika","description":"Helpful functions to extend the Golang `time` standard package","archived":false,"fork":false,"pushed_at":"2024-01-30T03:52:07.000Z","size":107,"stargazers_count":19,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T09:22:30.286Z","etag":null,"topics":["date","go","golang","golang-library","time"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bartmika.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-01-09T22:58:30.000Z","updated_at":"2024-07-06T15:44:24.000Z","dependencies_parsed_at":"2024-01-30T04:49:38.593Z","dependency_job_id":null,"html_url":"https://github.com/bartmika/timekit","commit_stats":null,"previous_names":["bartmika/go-timekit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartmika%2Ftimekit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartmika%2Ftimekit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartmika%2Ftimekit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartmika%2Ftimekit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bartmika","download_url":"https://codeload.github.com/bartmika/timekit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250384731,"owners_count":21421784,"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":["date","go","golang","golang-library","time"],"created_at":"2024-11-10T04:24:53.048Z","updated_at":"2025-04-23T06:30:49.787Z","avatar_url":"https://github.com/bartmika.png","language":"Go","readme":"# timekit\n[![GoDoc](https://godoc.org/github.com/gomarkdown/markdown?status.svg)](https://pkg.go.dev/github.com/bartmika/timekit)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bartmika/timekit)](https://goreportcard.com/report/github.com/bartmika/timekit)\n[![License](https://img.shields.io/github/license/bartmika/timekit)](https://github.com/bartmika/timekit/blob/master/LICENSE)\n![Go version](https://img.shields.io/github/go-mod/go-version/bartmika/timekit)\n\nConvenience functions to make your life easier when using with Golang's [`time`](https://pkg.go.dev/time) package.\n\n## Installation\n\nIn your Golang project, please run:\n\n```\ngo get github.com/bartmika/timekit\n```\n\n## Documentation\n\nAll [documentation](https://pkg.go.dev/github.com/bartmika/timekit) can be found here.\n\n## Example Usage\nThe following usage section will show a few interesting solutions that can be solved by this library.\n\n### How do I get the first day of this year in Golang?\n\n```go\nimport (\n    \"fmt\"\n\n    \"github.com/bartmika/timekit\"\n)\n\nstartOfYearDate := timekit.FirstDayOfThisYear(time.Now)\nfmt.Println(startOfYearDate)\n```\n\nIf you have interest in finding out more functions for getting different date/times then checkout [timekit.go](timekit.go) file.\n\n### How do parse JavaScript time into Golang time?\n\nIn your browser console, try writing this:\n```javascript\n// EXAMPLE JAVASCRIPT CODE\nvar dt = new Date()\nconsole.log(dt.getTime()) // 1643082322380\nconsole.log(dt) // Mon Jan 24 2022 22:45:22 GMT-0500 (Eastern Standard Time)\n```\n\nThen try this in your go source file:\n\n```go\nimport (\n    \"fmt\"\n\n    \"github.com/bartmika/timekit\"\n)\n\njsTime := int64(1643082322380)\ngoTime := ParseJavaScriptTime(jsTime)\nfmt.Println(goTime)\n```\n\n### How get a range of date/times between two dates?\n\n```go\nimport (\n    \"fmt\"\n\n    \"github.com/bartmika/timekit\"\n)\n\nstart := time.Date(2022, 1, 7, 1, 0, 0, 0, loc) // Jan 7th 2022\nend := time.Date(2022, 1, 10, 1, 0, 0, 0, loc)  // Jan 10th 2022\ndts := RangeFromTimeStepper(start, end, 0, 0, 1, 0, 0, 0) // Step by day.\nfmt.Println(dts) // Output:\n                 // Jan 7th 2022\n                 // Jan 8th 2022\n                 // Jan 9th 2022\n                 // Jan 10th 2022\n```\n\nIf you have interest in finding out more range functions then checkout [range.go](range.go) and [timestepper.go](timestepper.go) files.\n\n\n### How get iterate between two dates?\n\n```go\nimport (\n    \"fmt\"\n\n    \"github.com/bartmika/timekit\"\n)\n\nloc := time.UTC                                 // closure can be used if necessary\nstart := time.Date(2022, 1, 7, 1, 0, 0, 0, loc) // Jan 7th 2022\nend := time.Date(2022, 1, 10, 1, 0, 0, 0, loc)  // Jan 10th 2022\nts := NewTimeStepper(start, end, 0, 0, 1, 0, 0, 0)\n\nvar actual time.Time\nrunning := true\nfor running {\n    // Get the value we are on in the timestepper.\n    actual = ts.Get()\n\n    log.Println(actual) // For debugging purposes only.\n\n    // Run our timestepper to get our next value.\n    ts.Next()\n\n    running = ts.Done() == false\n}\n```\n\nIf you have interest in finding out iterating between two date/times then checkout [timestepper.go](timestepper.go) file.\n\n## Contributing\n\nFound a bug? Want a feature to improve your developer experience when dealing with the [`time`](https://pkg.go.dev/time) package? Please create an [issue](https://github.com/bartmika/timekit/issues).\n\n## License\nMade with ❤️ by [Bartlomiej Mika](https://bartlomiejmika.com).   \nThe project is licensed under the [ISC License](LICENSE).\n\nResource used:\n\n* [Stubbing Time.Now() in golang](https://labs.yulrizka.com/en/stubbing-time-dot-now-in-golang/) was a tremendous help in getting me to understand how to unit test with the [`time.Time`](https://pkg.go.dev/time) package.\n* [dannav/hhmmss](https://github.com/dannav/hhmmss) package is used for the Golang `hh:mm:ss` string to duration conversation method.\n* [relvacode/iso8601](https://github.com/relvacode/iso8601) package is used for dealing with ISO8601 formatted strings.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartmika%2Ftimekit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartmika%2Ftimekit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartmika%2Ftimekit/lists"}