The Inner Drive Extensible Architecture™—the Idea™

Demonstration: Time zones

The IDEA™ includes a fully-object-oriented, easy-to-integrate set of tools to allow you to use the Internet-standard tzinfo database—used throughout the world on millions of Unix computers—in your .NET apps.

Explore time zones

We've loaded 529 time zones for you to check out:

Choose a world region
Find the zone name
Current time
UTC Sunday, January 16, 2022 9:56:16 PM UTC
Inner Drive HQ Sunday, January 16, 2022 3:56:16 PM CST
America/Chicago Sunday, January 16, 2022 3:56:16 PM CST

Buy a license

If you want to use the IDEA™ in your commercial application, check out our licensing options.

How this works

The time zone handling classes are in the InnerDrive.TimeZones assembly. Most are internal to the assembly; generally, you only need to work with the TimeZoneFactory class. The factory parses the raw tzinfo database and makes it available through an injectable instance.

First, the appSettings.json file needs the following keys:

	"timeZoneSettings": {
		"defaultTimeZoneHomeZone": "America/Chicago",
		"storageConnectionString": "Your Azure storage account connection string",
		"throwOnFailure": "false",
		"timeZoneBlobName": "timezonedata"

At application start, the factory initializes. The Application_Start event handler calls this method (using AutoFac for dependency injection):

private void InitializeTimeZones()
	Trace.WriteLine("Initializing time zones");
	var factory = ContainerProvider.RequestLifetime.Resolve<ITimeZoneFactory>();
		"Time zones initialized? {0}", factory.Initialized));

(By default, the factory will throw an exception if a time zone definition is corrupt. Use the "throwOnFailure" setting to prevent that behavior.)

At this point, you can use the default time zone—on this site, "America/Chicago", UTC-06:00—in one method call:

var thisZone = TimeZoneFactory.DefaultTimeZone;
var localTime = thisZone.ToLocalTime(DateTimeOffset.UtcNow);

Using a different zone is almost that easy. You simply call the TimeZoneFactory.FindZone method with the name of the zone you want. Here's the code from this page's code-behind:

// Exposed property for dependency injection
public ITimeZoneFactory TimeZoneFactory { get; set; }

private void SetLocalTime()
   var localZone = SelectedZone;
   resultPrompt.Text = localZone.Name;
   SetText(localZone, resultText);

private void SetText(IdtTimeZone timeZone, ITextControl control)
   var currentInfo = timeZone.CurrentInfo(SelectedTime);
   control.Text = string.Format(CultureInfo.CurrentCulture, "{0:D} {0:T} {1}",

Behind the scenes, time zone information is cached, making lookups very fast, and saving the trouble (and computing resources) of loading the tzinfo database again.

More information

For more information, send us some feedback and someone will get right back to you.

InnerDrive.TimeZones 4.0.7306.0 Release CLR 4.0.30319.42000
Copyright ©2020 Inner Drive Technology. All rights reserved. Portions Copyright ©1986-2020 David Braverman.

Return home.

Copyright ©2022 Inner Drive Technology. Purveyors of fine, hand-crafted computer software. Legal information. Page printed 2022-01-16T21:56:16 UTC.