{"id":23223353,"url":"https://github.com/imantung/timex","last_synced_at":"2025-09-06T02:38:26.745Z","repository":{"id":74693372,"uuid":"291202505","full_name":"imantung/timex","owner":"imantung","description":"Freeze time and error-safe parse functions for go","archived":false,"fork":false,"pushed_at":"2020-08-29T09:42:20.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T16:36:18.252Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/imantung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-08-29T04:46:50.000Z","updated_at":"2020-08-29T09:30:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"6187da11-9e47-45e8-8de8-f08d7261602a","html_url":"https://github.com/imantung/timex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/imantung/timex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imantung%2Ftimex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imantung%2Ftimex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imantung%2Ftimex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imantung%2Ftimex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imantung","download_url":"https://codeload.github.com/imantung/timex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imantung%2Ftimex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273849647,"owners_count":25179192,"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-09-06T02:00:13.247Z","response_time":2576,"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-18T23:17:08.520Z","updated_at":"2025-09-06T02:38:26.709Z","avatar_url":"https://github.com/imantung.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/imantung/timex)](https://goreportcard.com/report/github.com/imantung/timex)\n[![Coverage](https://gocover.io/_badge/github.com/imantung/timex)](https://gocover.io/github.com/imantung/timex)\n\n# timex\n\nReally simple time wrapper package\n\n## Freeze Time \n\nReplace `time.Now` with `timex.Now`\n\nFreeze by function:\n```go\ntimex.Freeze(func() time.Time {\n    return time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)\n})\ndefer timex.Unfreeze()\n\nfmt.Println(timex.Now().Format(time.RFC3339))\n\n// Output: 2009-11-10T23:00:00Z\n```\n\nFreeze by specific time:\n```go\ntimex.FreezeByTime(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC))\ndefer timex.Unfreeze()\n\nfmt.Println(timex.Now().Format(time.RFC3339))\n\n// Output: 2009-11-10T23:00:00Z\n```\n\nFreeze by specific rfc3339 formatted string:\n```go\ntimex.FreezeByRFC3339(\"2020-08-29T14:21:00Z\")\ndefer timex.Unfreeze()\n\nfmt.Println(timex.Now().Format(time.RFC3339))\n\n// Output: 2020-08-29T14:21:00Z\n```\n\n## Error-Safe Parse Functions\n\nStandard time parse function without error\n\nUse `timex.ParseDuration` to parses a duration string:\n```go\nfmt.Printf(\"%d\\n\", timex.ParseDuration(\"1h\"))\n\n// Output: 3600000000000\n```\n\nUse `timex.Parse` to parses a formatted string and returns the time value it represents:\n```go\nconst longForm = \"Jan 2, 2006 at 3:04pm (MST)\"\nfmt.Println(timex.Parse(longForm, \"Feb 3, 2013 at 7:54pm (PST)\"))\n\n// Output: 2013-02-03 19:54:00 +0000 PST\n```\n\nUse `timex.ParseInLocation` to parsed a formatted string using location:\n```go\nloc, _ := time.LoadLocation(\"Europe/Berlin\")\n\n// This will look for the name CEST in the Europe/Berlin time zone.\nconst longForm = \"Jan 2, 2006 at 3:04pm (MST)\"\nfmt.Println(timex.ParseInLocation(longForm, \"Jul 9, 2012 at 5:02am (CEST)\", loc))\n\n// Output: 2012-07-09 05:02:00 +0200 CEST\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimantung%2Ftimex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimantung%2Ftimex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimantung%2Ftimex/lists"}