{"id":29883459,"url":"https://github.com/nitroshare/mocktime","last_synced_at":"2025-09-12T23:38:40.887Z","repository":{"id":306833682,"uuid":"1027328519","full_name":"nitroshare/mocktime","owner":"nitroshare","description":"Go package to simplify mocking time functions for deterministic testing","archived":false,"fork":false,"pushed_at":"2025-08-10T23:28:55.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-11T01:12:27.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/nitroshare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2025-07-27T19:45:25.000Z","updated_at":"2025-08-10T23:28:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"d612c3ca-32af-415b-abb7-0ae3fc8a29cb","html_url":"https://github.com/nitroshare/mocktime","commit_stats":null,"previous_names":["nitroshare/mocktime"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/nitroshare/mocktime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitroshare%2Fmocktime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitroshare%2Fmocktime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitroshare%2Fmocktime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitroshare%2Fmocktime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitroshare","download_url":"https://codeload.github.com/nitroshare/mocktime/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitroshare%2Fmocktime/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274893730,"owners_count":25369387,"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-12T02:00:09.324Z","response_time":60,"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":"2025-07-31T13:20:08.577Z","updated_at":"2025-09-12T23:38:40.875Z","avatar_url":"https://github.com/nitroshare.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## mocktime\n\n[![Build Status](https://github.com/nitroshare/mocktime/actions/workflows/test.yml/badge.svg)](https://github.com/nitroshare/mocktime/actions/workflows/test.yml)\n[![Coverage Status](https://coveralls.io/repos/github/nitroshare/mocktime/badge.svg?branch=main)](https://coveralls.io/github/nitroshare/mocktime?branch=main)\n[![Go Reference](https://pkg.go.dev/badge/github.com/nitroshare/mocktime.svg)](https://pkg.go.dev/github.com/nitroshare/mocktime)\n[![MIT License](https://img.shields.io/badge/license-MIT-9370d8.svg?style=flat)](https://opensource.org/licenses/MIT)\n\nThis package provides an easy way to mock specific functions in the `time` package:\n\n```golang\nimport \"github.com/nitroshare/mocktime\"\n\n// Same as time.Now()\nmocktime.Now()\n\n// Mock Now() and After()\nmocktime.Mock()\ndefer mocktime.Unmock()\n\n// All calls to Now() will return the same time...\nmocktime.Now()\n\n// ...until the time is advanced\nmocktime.Advance(5 * time.Second)\n\n// ...or explicitly set\nmocktime.Set(time.Date(2025, time.May, 1, 0, 0, 0, 0, time.UTC))\n\n// Calls to After() will block until the time is advanced (in another\n// goroutine, for example)\n\u003c-mocktime.After(5 * time.Second)\n\n// A drop-in replacement for time.Timer is provided:\nt := mocktime.NewTimer(10 * time.Second)\n\u003c-t.C\nt.Stop()\n\n// ...as well as time.Ticker:\nt := mocktime.NewTicker(1 * time.Second)\n\u003c-t.C\nt.Reset(2 * time.Second)\nt.Stop()\n```\n\n### Advanced Usage\n\nA special utility function is provided that blocks until the next call to `After()`:\n\n```golang\nchanDone := make(chan any)\n\ngo func() {\n\n    // Normally, this will block until Set() or Advance() is called\n    \u003c-mocktime.After(5 * time.Second)\n\n    close(chanDone)\n}()\n\n// Advance the time to the expiry of the After() call above; we don't need to\n// worry if the goroutine has reached the After() call or not when this\n// function is called as it will block until After() is called\nmocktime.AdvanceToAfter()\n\n// This read is guaranteed to succeed because the read on After() in the\n// goroutine is unblocked\n\u003c-chanDone\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitroshare%2Fmocktime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitroshare%2Fmocktime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitroshare%2Fmocktime/lists"}