TrickyMottram.UnitConversion.Time
1.0.1
dotnet add package TrickyMottram.UnitConversion.Time --version 1.0.1
NuGet\Install-Package TrickyMottram.UnitConversion.Time -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TrickyMottram.UnitConversion.Time" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TrickyMottram.UnitConversion.Time" Version="1.0.1" />
<PackageReference Include="TrickyMottram.UnitConversion.Time" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TrickyMottram.UnitConversion.Time --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TrickyMottram.UnitConversion.Time, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=TrickyMottram.UnitConversion.Time&version=1.0.1
#tool nuget:?package=TrickyMottram.UnitConversion.Time&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TrickyMottram.UnitConversion.Time
Time unit conversion implementation for the TrickyMottram Unit Conversion libraries.
This package provides an implementation of IUnitConverter
and IUnitRegistry
for converting between a wide range of time units including nanoseconds, seconds, days, and years. It is part of the TrickyMottram.UnitConversion ecosystem.
✨ Features
- Supports nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days, weeks, months, and years
- Supports both string-based and strongly typed enum-based conversion methods
- Integrates with the
UnitConversionService
orchestration layer - Fully compatible with dependency injection and Microsoft.Extensions.Logging
- Includes a unit registry for enumeration and UI binding
🔧 Usage Example
Add to Dependency Injection
services.AddSingleton<IUnitConverter, TimeConverter>();
services.AddSingleton<IUnitRegistry, TimeUnitRegistry>();
Convert via UnitConversionService
public class TimeController : ControllerBase
{
private readonly UnitConversionService _service;
public TimeController(UnitConversionService service)
{
_service = service;
}
[HttpGet]
public IActionResult ConvertTime(double value, string from, string to)
{
var result = _service.Convert(value, from, to);
return Ok(result);
}
}
Strongly Typed Conversion
double minutes = new TimeConverter(logger)
.Convert(3600, TimeUnit.Second, TimeUnit.Minute); // 60.0
📚 Main Types
TrickyMottram.UnitConversion.Time.TimeConverter
TrickyMottram.UnitConversion.Time.Registry.TimeUnitRegistry
TrickyMottram.UnitConversion.Time.Enums.TimeUnit
TrickyMottram.UnitConversion.Time.Extensions.TimeUnitExtensions
📦 Package Metadata
- Target Framework:
.NET 8
- License: MIT
- Source: GitHub Repository
- Tags:
unit conversion
,time
,duration
,datetime
,dotnet
✅ Contributing
Suggestions and PRs for expanding time unit support or improving conversions are welcome at GitHub Issues.
© Tricky Mottram
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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 was computed. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
- TrickyMottram.UnitConversion.Abstractions (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.1 | 67 | 6/20/2025 |