https://github.com/dimitrietataru/ace-csharp-time
C# time
https://github.com/dimitrietataru/ace-csharp-time
csharp datetime datetimeoffset datetimeprovider systemtime utc
Last synced: 26 days ago
JSON representation
C# time
- Host: GitHub
- URL: https://github.com/dimitrietataru/ace-csharp-time
- Owner: dimitrietataru
- License: mit
- Created: 2023-02-07T13:47:09.000Z (about 3 years ago)
- Default Branch: ace
- Last Pushed: 2025-04-14T03:52:30.000Z (11 months ago)
- Last Synced: 2025-09-06T01:35:54.571Z (6 months ago)
- Topics: csharp, datetime, datetimeoffset, datetimeprovider, systemtime, utc
- Language: C#
- Homepage:
- Size: 43.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C# time
[](https://github.com/dimitrietataru/ace-csharp-time/actions/workflows/build.yml)
[](https://github.com/dimitrietataru/ace-csharp-time/actions/workflows/release.yml)
[](https://www.nuget.org/packages/AceCSharp.Time)
### What is AceCSharp.Time
It's a library, that exposes DI-ready and mockable implementation of current date and time, or date and time with offset.
### Usage
``` csharp
IDateTimeProvider dateTimeProvider = new DateTimeProvider();
DateTime moment = dateTimeProvider.Now();
DateTime momentInUtc = dateTimeProvider.UtcNow();
DateTimeOffset momentWithOffset = dateTimeProvider.NowOffset();
DateTimeOffset momentWithZeroOffset = dateTimeProvider.UtcNowOffset();
```
``` csharp
ISystemTime systemTime = new SystemTime();
DateTime moment = systemTime.Now();
DateTime momentInUtc = systemTime.UtcNow();
```
### License
AceCSharp.Time is Copyright © 2022 [Dimitrie Tataru](https://github.com/dimitrietataru) and other contributors under the [MIT license](https://github.com/dimitrietataru/ace-csharp-time/blob/ace/LICENSE).