Lagersoft.UtcLocalConversion.DependencyInjection 1.0.0

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

Install-Package Lagersoft.UtcLocalConversion.DependencyInjection -Version 1.0.0
dotnet add package Lagersoft.UtcLocalConversion.DependencyInjection --version 1.0.0
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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();
	}
	

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();
	}
	

Release Notes

First release

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0 76 4/4/2019