CSharpEssentials.Time
3.0.4
dotnet add package CSharpEssentials.Time --version 3.0.4
NuGet\Install-Package CSharpEssentials.Time -Version 3.0.4
<PackageReference Include="CSharpEssentials.Time" Version="3.0.4" />
<PackageVersion Include="CSharpEssentials.Time" Version="3.0.4" />
<PackageReference Include="CSharpEssentials.Time" />
paket add CSharpEssentials.Time --version 3.0.4
#r "nuget: CSharpEssentials.Time, 3.0.4"
#:package CSharpEssentials.Time@3.0.4
#addin nuget:?package=CSharpEssentials.Time&version=3.0.4
#tool nuget:?package=CSharpEssentials.Time&version=3.0.4
CSharpEssentials.Time
Testable time abstraction built on .NET TimeProvider. Decouple your code from the system clock for reliable unit testing.
Features
- IDateTimeProvider — Injectable interface for
UtcNow,UtcNowDateTime,UtcNowDate, andUtcNowTime. - TimeProvider Integration — Works with .NET's built-in
TimeProviderandFakeTimeProviderfor testing. - DateTime Extensions — Convert
DateTimetoDateOnlyandTimeOnly.
Installation
dotnet add package CSharpEssentials.Time
Usage
DateTimeProvider
using CSharpEssentials.Time;
public class OrderService(IDateTimeProvider time)
{
public Order CreateOrder()
{
return new Order
{
CreatedAt = time.UtcNow,
CreatedDate = time.UtcNowDate
};
}
}
Dependency Injection
builder.Services.AddSingleton<TimeProvider>(TimeProvider.System);
builder.Services.AddSingleton<IDateTimeProvider, DateTimeProvider>();
Testing with FakeTimeProvider
using Microsoft.Extensions.Time.Testing;
FakeTimeProvider fakeTime = new();
fakeTime.SetUtcNow(new DateTimeOffset(2025, 1, 1, 0, 0, 0, TimeSpan.Zero));
IDateTimeProvider provider = new DateTimeProvider(fakeTime);
provider.UtcNow.Year.Should().Be(2025);
Extensions
DateTime now = DateTime.UtcNow;
DateOnly date = now.ToDateOnly();
TimeOnly time = now.ToTimeOnly();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Bcl.TimeProvider (>= 8.0.0)
-
net10.0
- No dependencies.
-
net11.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CSharpEssentials.Time:
| Package | Downloads |
|---|---|
|
CSharpEssentials
A comprehensive C# library enhancing functional programming capabilities with type-safe monads (Maybe, Result), discriminated unions (Any), and robust error handling. Features include: domain-driven design support, enhanced Entity Framework integration, testable time management, JSON utilities, and LINQ extensions. Built for modern C# development with focus on maintainability, testability, and functional programming principles. |
|
|
CSharpEssentials.Entity
Domain-driven design (DDD) entity base classes and patterns for CSharpEssentials. Provides EntityBase<TId> with soft delete functionality, audit trails, and domain event integration. Essential for building robust domain models with type safety and functional programming principles. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.4 | 54 | 5/6/2026 |
| 3.0.3 | 77 | 5/5/2026 |
| 3.0.2 | 143 | 5/5/2026 |
| 3.0.1 | 147 | 5/3/2026 |
| 3.0.0 | 146 | 5/3/2026 |
| 2.1.0 | 306 | 11/26/2025 |
| 2.0.9 | 263 | 9/30/2025 |
| 2.0.8 | 245 | 9/29/2025 |
| 2.0.7 | 255 | 9/29/2025 |
| 2.0.6 | 247 | 9/29/2025 |
| 2.0.5 | 242 | 9/29/2025 |
| 2.0.4 | 253 | 9/28/2025 |
| 2.0.3 | 239 | 9/28/2025 |
| 2.0.2 | 236 | 9/28/2025 |
| 2.0.1 | 253 | 9/28/2025 |
| 2.0.0 | 264 | 9/28/2025 |