{"id":19119007,"url":"https://github.com/journy-io/clock","last_synced_at":"2026-06-23T05:32:18.373Z","repository":{"id":57122182,"uuid":"336557817","full_name":"journy-io/clock","owner":"journy-io","description":"🕐 Consume time as a service","archived":false,"fork":false,"pushed_at":"2023-02-17T13:58:04.000Z","size":492,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-04T15:53:09.983Z","etag":null,"topics":["clock","magic","testing","time"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/journy-io.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":"2021-02-06T14:35:39.000Z","updated_at":"2021-11-16T12:24:50.000Z","dependencies_parsed_at":"2025-01-03T07:42:39.549Z","dependency_job_id":"8c5c6044-19f9-480d-a99d-34e73a973164","html_url":"https://github.com/journy-io/clock","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"599d8aa16d8e7109d7d021e3022fe6bab9f050d8"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":"journy-io/package","purl":"pkg:github/journy-io/clock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journy-io%2Fclock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journy-io%2Fclock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journy-io%2Fclock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journy-io%2Fclock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/journy-io","download_url":"https://codeload.github.com/journy-io/clock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/journy-io%2Fclock/sbom","scorecard":{"id":534919,"data":{"date":"2025-08-11","repo":{"name":"github.com/journy-io/clock","commit":"599d8aa16d8e7109d7d021e3022fe6bab9f050d8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build-and-release.yml:1","Warn: no topLevel permission defined: .github/workflows/lint-and-test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-release.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/journy-io/clock/build-and-release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-release.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/journy-io/clock/build-and-release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-and-test.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/journy-io/clock/lint-and-test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-and-test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/journy-io/clock/lint-and-test.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/build-and-release.yml:17","Warn: npmCommand not pinned by hash: .github/workflows/lint-and-test.yml:17","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/journy-io/.github/SECURITY.md:1","Info: Found linked content: github.com/journy-io/.github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/journy-io/.github/SECURITY.md:1","Info: Found text in security policy: github.com/journy-io/.github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}}]},"last_synced_at":"2025-08-20T06:41:29.519Z","repository_id":57122182,"created_at":"2025-08-20T06:41:29.519Z","updated_at":"2025-08-20T06:41:29.519Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34677382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"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","magic","testing","time"],"created_at":"2024-11-09T05:08:18.811Z","updated_at":"2026-06-23T05:32:18.343Z","avatar_url":"https://github.com/journy-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![journy.io](https://raw.githubusercontent.com/journy-io/brand/main/githubbanner.png)](https://journy.io/?utm_source=github\u0026utm_content=readme-clock)\n\n# Clock\n\n![npm](https://img.shields.io/npm/v/@journyio/clock?color=%234d84f5\u0026style=flat-square)\n[![npm downloads](https://img.shields.io/npm/dm/@journyio/clock?style=flat-square)](https://www.npmjs.com/package/@journyio/clock)\n\nConsume time as a service.\n\n## 💾 Installation\n\nYou can use your package manager (`npm` or `yarn`) to install:\n\n```bash\nnpm install --save @journyio/clock\n```\nor\n```bash\nyarn add @journyio/clock\n```\n\nThis package depends on [moment/luxon](https://github.com/moment/luxon). If you already have another datetime library installed in your project, we advise you to fork this package.\n\nWe don't recommend consuming this package in plain JavaScript (to be able to use interfaces).\n\n## 🔌 Getting started\n\nFirst, [read this blogpost](https://blog.frankdejonge.nl/being-in-control-of-time-in-php/) to understand the reasoning behind this approach.\n\nLet's say we have a class that creates a user:\n\n```ts\nimport { DateTime } from \"luxon\";\nimport { Clock } from \"@journyio/clock\";\n\nclass User {\n  constructor(/* ... */ private readonly createdAt: DateTime) {}\n\n  getCreatedAt() {\n    return this.createdAt;\n  }\n}\n\nclass UserService {\n  constructor(private readonly clock: Clock) {}\n\n  create(/* ... */): User {\n    return new User(\n      /* ... */\n      this.clock.getUTCTime()\n    );\n  }\n}\n```\n\nIn our tests we can use `ClockFixed` to control the current time:\n\n```ts\nimport { ClockFixed } from \"@journyio/clock\";\n\nconst now = DateTime.utc();\nconst clock = new ClockFixed(now);\nconst userService = new UserService(clock);\nconst user = userService.create(/* ... */);\n\nexpect(user.getCreatedAt()).toEqual(now);\n```\n\nIn our normal code we can use `ClockSystem`:\n\n```ts\nimport { ClockSystem } from \"@journyio/clock\";\n\nconst userService = new UserService(new ClockSystem());\n```\n\nBy depending on `Clock` we can consume time as a service (so that we're in control of time). Normally we would need to rely on magic or use `setTimeout` to test code that uses the current time. \n\n## 💯 Tests\n\nTo run the tests:\n\n```bash\nnpm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjourny-io%2Fclock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjourny-io%2Fclock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjourny-io%2Fclock/lists"}