{"id":17187105,"url":"https://github.com/tocsoft/datetimeabstractions","last_synced_at":"2025-10-13T02:32:01.504Z","repository":{"id":54861696,"uuid":"119503308","full_name":"tocsoft/DateTimeAbstractions","owner":"tocsoft","description":"Provides a test friendly wrapper over DateTime static properties","archived":false,"fork":false,"pushed_at":"2021-01-25T18:59:42.000Z","size":106,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-06T07:53:57.959Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","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/tocsoft.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}},"created_at":"2018-01-30T08:07:17.000Z","updated_at":"2021-01-25T18:59:44.000Z","dependencies_parsed_at":"2022-08-14T05:00:54.757Z","dependency_job_id":null,"html_url":"https://github.com/tocsoft/DateTimeAbstractions","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tocsoft/DateTimeAbstractions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tocsoft%2FDateTimeAbstractions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tocsoft%2FDateTimeAbstractions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tocsoft%2FDateTimeAbstractions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tocsoft%2FDateTimeAbstractions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tocsoft","download_url":"https://codeload.github.com/tocsoft/DateTimeAbstractions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tocsoft%2FDateTimeAbstractions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014020,"owners_count":26085345,"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-10-13T02:00:06.723Z","response_time":61,"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-10-15T01:05:22.190Z","updated_at":"2025-10-13T02:32:01.208Z","avatar_url":"https://github.com/tocsoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tocsoft.DateTimeAbstractions\n\n**Tocsoft.DateTimeAbstractions** is a testable alternative to the static `DateTime.Now` and `DateTimeOffset.Now` methods.\n\n\n[![.NET](https://github.com/tocsoft/DateTimeAbstractions/workflows/.NET/badge.svg?branch=master)](https://github.com/tocsoft/DateTimeAbstractions/actions?query=workflow%3A.NET+branch%3Amaster)\n[![codecov](https://codecov.io/gh/Tocsoft/DateTimeAbstractions/branch/master/graph/badge.svg)](https://codecov.io/gh/Tocsoft/DateTimeAbstractions)\n[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/Tocsoft/DateTimeAbstractions/master/LICENSE)\n\n[![GitHub issues](https://img.shields.io/github/issues/Tocsoft/DateTimeAbstractions.svg)](https://github.com/Tocsoft/DateTimeAbstractions/issues)\n[![GitHub stars](https://img.shields.io/github/stars/Tocsoft/DateTimeAbstractions.svg)](https://github.com/Tocsoft/DateTimeAbstractions/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/Tocsoft/DateTimeAbstractions.svg)](https://github.com/Tocsoft/DateTimeAbstractions/network)\n\n\n### Installation\n\nWe also have a [MyGet package repository](https://www.myget.org/gallery/tocsoft) - for bleeding-edge / development NuGet releases.\n\n### Usage\n\nUsing `Tocsoft.DateTimeAbstractions` is as simple as switching out all usages of `DateTime.Now` with `Clock.Now` and your done your businesslogic thats dependent of on getting the current time is now more testable.\n\n### Using `Tocsoft.DateTimeAbstractions`  from Tests\n\nNow your code is using `Clock.Now` you can now wrap your code under test like so \n\n```c#\nusing (Clock.Pin(new DateTime(2018, 02, 02))) \n{  \n\t// Clock.Now will always return the pinned value until the using block has ended.\n\tAssert.Equal(new DateTime(2018, 02, 02), Clock.Now);\n}\n```` \n\n### Additional APIs \n\nYou probably aren't using DateTime.Now in you code so how can this library help? well we support all the static properties from `DateTime` and `DateTimeOffset` so any of this properties can be switched out and tested.\n\n| System API             | DateTimeAbstractions Replacement |\n|------------------------|----------------------------------|\n| `DateTime.Now`         | `Clock.Now`                      |\n| `DateTime.UtcNow`      | `Clock.UtcNow`                   |\n| `DateTime.Today`       | `Clock.Today`                    |\n| `DateTimeOffset.Now`   | `ClockOffset.Now`                |\n| `DateTimeOffset.UtcNow`| `ClockOffset.UtcNow`             |\n\u003e We include warnings and code fixes for all these mappings.\n\nIn addition to the `DateTime` set of APIs we also include a testable wrapper around using the `Stopwatch` class in the form of the `ClockTimer` as with the `Clock` APIs we support pinning for testing purposes.\n\n### The Team\n\nLead\n- [Scott Williams](https://github.com/tocsoft)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftocsoft%2Fdatetimeabstractions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftocsoft%2Fdatetimeabstractions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftocsoft%2Fdatetimeabstractions/lists"}