Lagersoft.UtcLocalConversion.DependencyInjection 1.0.0

dotnet add package Lagersoft.UtcLocalConversion.DependencyInjection --version 1.0.0
NuGet\Install-Package Lagersoft.UtcLocalConversion.DependencyInjection -Version 1.0.0
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="Lagersoft.UtcLocalConversion.DependencyInjection" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lagersoft.UtcLocalConversion.DependencyInjection --version 1.0.0
#r "nuget: Lagersoft.UtcLocalConversion.DependencyInjection, 1.0.0"
#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.
// Install Lagersoft.UtcLocalConversion.DependencyInjection as a Cake Addin
#addin nuget:?package=Lagersoft.UtcLocalConversion.DependencyInjection&version=1.0.0

// Install Lagersoft.UtcLocalConversion.DependencyInjection as a Cake Tool
#tool nuget:?package=Lagersoft.UtcLocalConversion.DependencyInjection&version=1.0.0

UTC to Local conversion for Net Core 2.2

This is a simple tool to integrate a date conversion library based on Noda Time with net core dependency injection.

The service will search for a configuration parameter named defaultTimeZoneId to know which time zone id will be using for the conversions.

To use, simply call

DateTimeModule.AddUtcLocalConversion()

Example Startup.cs

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    services
	    .AddMvc()
	    .AddUtcLocalConversion();
}

Example appsettings.json

{
	"DefaultTimeZoneId": "America/Guatemala"
}

For now, it has three main usages.

DateTimeLocalizer

Used to make conversions between some local and UTC.

dateTimeLocalizer = new DateTimeLocalizer("America/Guatemala");

DateTimeLocalizerService

Is build on top of DateTimeLocalizer, but is made to take advantage of the Dependency Injection.

This class should be injected, with the configuration like in the Examples, and allows to convert between a particular TimeZoneId (defined in the configuration) and UTC.

	public SomeServiceConstructor(DateTimeLocalizerService dateTimeLocalizerService)
	{
		_dateTimeLocalizerService = dateTimeLocalizerService;
	}

	public void SomeFunction()
	{
		var someLocalDateTime = _dateTimeLocalizerService.UtcToLocalDateTime(DateTime.UtcNow);
	}

DateTimeProviderService

As DateTimeLocalizerService, it needs the Dependency Injection configuration.

The class allows to get some common date functions.

	public SomeServiceConstructor(DateTimeProviderService dateTimeProviderService)
	{
		_dateTimeProviderService = dateTimeProviderService;
	}

	public void SomeFunction()
	{
		var localStartOfDayInUtcForDbReport = _dateTimeProviderService.TodayLocalInUtc();
	}
	
Product 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. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0 568 4/4/2019

First release