https://github.com/dimitrietataru/ace-csharp-time
C# time
https://github.com/dimitrietataru/ace-csharp-time
csharp datetime datetimeoffset datetimeprovider systemtime utc
Last synced: 5 months 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 (almost 3 years ago)
- Default Branch: ace
- Last Pushed: 2024-10-24T11:16:38.000Z (about 1 year ago)
- Last Synced: 2024-11-08T16:13:14.839Z (about 1 year ago)
- Topics: csharp, datetime, datetimeoffset, datetimeprovider, systemtime, utc
- Language: C#
- Homepage:
- Size: 34.2 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).