RegionTime 1.0.0
dotnet add package RegionTime --version 1.0.0
NuGet\Install-Package RegionTime -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="RegionTime" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RegionTime" Version="1.0.0" />
<PackageReference Include="RegionTime" />
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 RegionTime --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RegionTime, 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.
#:package RegionTime@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RegionTime&version=1.0.0
#tool nuget:?package=RegionTime&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RegionTime
[](https://www.nuget.org/packages/RegionTime/)
Lightweight .NET library for **region-specific time conversion**, supporting both **Windows** and **IANA** timezone identifiers.
Cross-platform • DI-ready • Fast & Safe • No source code exposed
---
## Quick Start
### Install via NuGet
```bash
dotnet add package RegionTime --version 1.0.0
Direct Usage
using RegionTime.Services;
var timeService = new RegionTimeService();
Console.WriteLine(timeService.Now("Asia/Karachi"));
Console.WriteLine(timeService.FromUtc(DateTime.UtcNow, "America/New_York"));
Console.WriteLine(timeService.IsDaylightSavingTime(DateTime.UtcNow, "Europe/London"));
Using Dependency Injection (ASP.NET Core, etc.)
using Microsoft.Extensions.DependencyInjection;
using RegionTime.Extensions;
var services = new ServiceCollection();
services.AddRegionTime();
var provider = services.BuildServiceProvider();
var timeService = provider.GetRequiredService<IRegionTimeService>();
Console.WriteLine(timeService.Now("America/Los_Angeles"));
Features
Now(string timeZone)– Get current time in any timezoneFromUtc(DateTime utc, string timeZone)– Convert UTC → localIsDaylightSavingTime(DateTime dateTime, string timeZone)– DST checkConvertByOffset(DateTime dateTime, double offsetHours)– Simple offset conversionGetAllTimeZones()– List all available system timezones- Full support for both IANA (
Asia/Tokyo) and Windows (Pacific Standard Time) IDs - Cross-platform (Windows, Linux, macOS)
- Built-in caching → blazing fast after first use
- Safe fallback + clear exceptions on invalid timezone IDs
- Dependency Injection ready
Exception Handling
try
{
var dt = timeService.Now("Invalid/Zone");
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
// Output: The timezone ID 'Invalid/Zone' is invalid or not recognized...
}
Public API Reference
IRegionTimeService
| Method | Parameters | Return Type | Description |
|---|---|---|---|
Now |
string timeZone |
DateTime |
Current local time in the specified timezone |
FromUtc |
DateTime utcDateTime, string timeZone |
DateTime |
Convert UTC time to target timezone |
IsDaylightSavingTime |
DateTime dateTime, string timeZone |
bool |
Check if given time is in DST |
ConvertByOffset |
DateTime dateTime, double offsetHours |
DateTime |
Simple offset-based conversion |
GetAllTimeZones |
— | IReadOnlyList<TimeZoneInfo> |
All system timezones |
Dependency Injection
public static IServiceCollection AddRegionTime(this IServiceCollection services)
Registers IRegionTimeService as a singleton.
Performance
Benchmarked with BenchmarkDotNet – extremely fast thanks to internal timezone caching.
Notes
- Powered by TimeZoneConverter for perfect IANA ↔ Windows mapping
License
MIT License – free for personal and commercial use.
Enjoy accurate, hassle-free timezone handling!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.1)
- TimeZoneConverter (>= 7.2.0)
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 | 380 | 12/10/2025 |