{"id":40896593,"url":"https://github.com/anothermemory/clock","last_synced_at":"2026-01-22T02:24:01.732Z","repository":{"id":57552811,"uuid":"116190378","full_name":"anothermemory/clock","owner":"anothermemory","description":"Simple clock library that can be mocked for testing if needed","archived":false,"fork":false,"pushed_at":"2018-01-20T15:54:39.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T00:38:23.295Z","etag":null,"topics":["clock","go","golang","mock","time"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anothermemory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-03T22:58:42.000Z","updated_at":"2018-01-04T00:17:12.000Z","dependencies_parsed_at":"2022-09-26T18:50:52.953Z","dependency_job_id":null,"html_url":"https://github.com/anothermemory/clock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/anothermemory/clock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anothermemory%2Fclock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anothermemory%2Fclock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anothermemory%2Fclock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anothermemory%2Fclock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anothermemory","download_url":"https://codeload.github.com/anothermemory/clock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anothermemory%2Fclock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28651386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["clock","go","golang","mock","time"],"created_at":"2026-01-22T02:24:01.646Z","updated_at":"2026-01-22T02:24:01.722Z","avatar_url":"https://github.com/anothermemory.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Another Memory Clock\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/anothermemory/clock)](https://goreportcard.com/report/github.com/anothermemory/clock)\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/anothermemory/clock)\n[![Coveralls github](https://img.shields.io/coveralls/github/anothermemory/clock.svg?style=flat-square)](https://coveralls.io/github/anothermemory/clock)\n[![Release](https://img.shields.io/github/release/anothermemory/clock.svg?style=flat-square)](https://github.com/anothermemory/clock/releases/latest)\n[![license](https://img.shields.io/github/license/anothermemory/clock.svg?style=flat-square)](LICENSE.md)\n[![Codacy grade](https://img.shields.io/codacy/grade/ae74d2f501bc4628ae7008c6f28a98b8.svg?style=flat-square)](https://www.codacy.com/app/anothermemory/clock)\n\nThis library contains interface and set of implementations for getting current time. For production usage\ntime must be mostly real time. For testing purposes it's often much easier to use mocked time so it will\nreturn required time each time.\n\nTable of Contents\n=================\n\n* [Another Memory Clock](#another-memory-clock)\n* [Table of Contents](#table-of-contents)\n  * [Getting Started](#getting-started)\n    * [Prerequisites](#prerequisites)\n    * [Installing](#installing)\n    * [See it in action](#see-it-in-action)\n      * [Mocked clock for testing](#mocked-clock-for-testing)\n      * [Real clock for production](#real-clock-for-production)\n  * [Built With](#built-with)\n  * [Contributing](#contributing)\n  * [Versioning](#versioning)\n  * [Authors](#authors)\n  * [License](#license)\n\n## Getting Started\n\n### Prerequisites\n\nThe project is tested with go 1.9 but probably will work with earlier versions.\n\n### Installing\n\nSimple go get it\n\n```bash\ngo get github.com/anothermemory/clock\n```\n\n### See it in action\n\n#### Mocked clock for testing\n\n```go\npackage clock_test\n\nimport (\n    \"time\"\n    \n    \"github.com/anothermemory/clock\"\n)\n\nfunc ExampleMock() {\n\tvar dummyTime = time.Date(2017, 11, 24, 17, 0, 0, 0, time.Local)\n\tc := clock.NewMock(dummyTime)\n\tc.Now() // Will return dummyTime each time\n}\n\nfunc ExampleMockPartial() {\n\tfirstTime := time.Date(2017, 11, 24, 17, 0, 0, 0, time.Local)\n    secondTime := time.Date(2018, 11, 24, 17, 0, 0, 0, time.Local)\n\n    c := clock.NewMockPartial(firstTime, secondTime)\n    c.Now() // This will return firstTime\n    c.Now() // This will return secondTime\n    c.Now() // This will return real time\n}\n```\n\n#### Real clock for production\n\n```go\npackage clock_test\n\nimport (\n    \"time\"\n    \n    \"github.com/anothermemory/clock\"\n)\n\nfunc ExampleReal() {\n    c := clock.NewReal()\n    c.Now() // Will return real current time \n}\n```\n\n## Built With\n\n* [dep](https://github.com/golang/dep) - The dependency management tool for Go\n\n## Contributing\n\nPlease read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details on our code of conduct, and [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/anothermemory/clock/tags). \n\n## Authors\n\n* **Vyacheslav Enis**\n\nSee also the list of [contributors](https://github.com/anothermemory/clock/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanothermemory%2Fclock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanothermemory%2Fclock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanothermemory%2Fclock/lists"}