TzData.Runtime.Linux 1.0.1

dotnet add package TzData.Runtime.Linux --version 1.0.1
                    
NuGet\Install-Package TzData.Runtime.Linux -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="TzData.Runtime.Linux" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TzData.Runtime.Linux" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TzData.Runtime.Linux" />
                    
Project file
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 TzData.Runtime.Linux --version 1.0.1
                    
#r "nuget: TzData.Runtime.Linux, 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.
#:package TzData.Runtime.Linux@1.0.1
                    
#: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=TzData.Runtime.Linux&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TzData.Runtime.Linux&version=1.0.1
                    
Install as a Cake Tool

TzData.Runtime.Linux

Linux-only app-local IANA time zone data for .NET.

Renamed from TzData.Runtime 1.0.0. This package targets Linux only; macOS already ships tzdata, and Windows uses NLS/registry.

.NET's TimeZoneInfo reads TZif files from TZDIR (default /usr/share/zoneinfo). Slim Linux images such as Alpine, Chiseled and Distroless do not ship tzdata, so TimeZoneInfo.FindSystemTimeZoneById("Europe/Kyiv") throws TimeZoneNotFoundException, while TimeZoneInfo.Local silently falls back to UTC. ICU packages do not fix this: ICU data and .NET's TimeZoneInfo are separate.

This package ships the compiled TZif tree (Europe/Kyiv, Etc/UTC, ... plus zone.tab) and sets TZDIR explicitly:

<ItemGroup>
  <PackageReference Include="TzData.Runtime.Linux" Version="1.0.1" />
</ItemGroup>
using TzData.Runtime.Linux;

// Call once, as early as possible (before the first TimeZoneInfo use).
TzDataRuntime.Configure(defaultTimeZoneId: "Asia/Shanghai");

var kyiv = TimeZoneInfo.FindSystemTimeZoneById("Europe/Kyiv");
Console.WriteLine(TimeZoneInfo.Local.Id);   // Asia/Shanghai

The tzdata folder is copied next to the application by buildTransitive targets for Linux targets. No system tzdata, root access or container changes are required.

API

namespace TzData.Runtime.Linux;

public static class TzDataRuntime
{
    public static string DataVersion { get; }   // e.g. "2026f"
    public static string DataDirectory { get; } // <app>/tzdata
    public static bool IsSupported { get; }     // true only on Linux
    public static bool IsConfigured { get; }    // TZDIR is set
    public static bool Configure(
        string? directory = null,
        string? defaultTimeZoneId = null,
        bool overwrite = false);
}
  • Configure() sets TZDIR only when it is not already set; pass overwrite: true to replace it.
  • defaultTimeZoneId sets TZ only when TZ is not already set. Without it, Local stays on /etc/localtime or falls back to UTC.
  • TimeZoneInfo.ClearCachedData() runs after configuration.
  • directory can point at a custom location (for example a read-only mount).
  • On macOS/Windows IsSupported is false and Configure() returns false without changing the environment.

Automatic setup (optional)

Reference the companion package to run Configure() from a module initializer, with no code:

<PackageReference Include="TzData.Runtime.Linux.AutoInit" Version="1.0.1" />

It can also bake in a default local time zone (applied with higher priority than TZ):

<PropertyGroup>
  <TzDataRuntimeAutoInitTimeZone>Asia/Shanghai</TzDataRuntimeAutoInitTimeZone>
</PropertyGroup>

See README-AUTOINIT.md for the exact guarantees, precedence and opt-outs.

Agent skill (SKILL.md)

Both packages ship an Agent Skill at skills/tzdata-runtime-linux/SKILL.md. Agents can discover it from the restored package:

dotnet-inspect package TzData.Runtime.Linux -S Skills
dotnet-package-skills install
ls ~/.nuget/packages/tzdata.runtime.linux/*/skills/

The skill is frozen inside each .nupkg and covers TZDIR/TZ precedence, the AutoInit default zone, verification snippets and troubleshooting.

Containers

# Nothing to install: the app carries tzdata and sets TZDIR in code.
COPY --from=build /app/publish /app
WORKDIR /app
ENTRYPOINT ["./MyApp"]

If you prefer the environment instead of code:

ENV TZDIR=/app/tzdata
ENV TZ=Asia/Shanghai

TZDIR is process-wide and inherited by child processes; it never modifies the host or /usr/share/zoneinfo.

Platform behavior

Platform Behavior
Linux (glibc/musl) TZDIR + app-local TZif; works on Alpine/Chiseled/Distroless
macOS Not supported (system tzdata is always present); Configure() is a no-op
Windows Not supported (NLS/registry); Configure() is a no-op

Data and versioning

  • Package 1.0.1 bundles IANA tzdata 2026f (TzDataRuntime.DataVersion).
  • Package version and tzdata version are independent: tzdata updates ship as 1.0.2, 1.0.3, ...
  • The tzdata/ folder is copied only for Linux RIDs (or portable builds on a Linux host); disable with TzDataRuntimeCopyData=false.
  • GetSystemTimeZones() enumerates zone.tab; if you trim the data folder, keep zone.tab for full enumeration and the individual TZif files for lookups.

Building

# Regenerate tzdata/ from IANA (requires zic + curl + sha512sum)
./scripts/build-tzdata.sh 2026f

# Verify the committed data matches the release
./scripts/build-tzdata.sh 2026f --verify

# Pack
dotnet pack src/TzData.Runtime/TzData.Runtime.csproj -c Release -o nupkg
dotnet pack src/TzData.Runtime.AutoInit/TzData.Runtime.AutoInit.csproj -c Release -o nupkg

License

  • Managed code and build scripts: Apache-2.0 (see LICENSE).
  • Bundled IANA tzdata: public domain (see LICENSE-TZDATA).
Product 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

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TzData.Runtime.Linux:

Package Downloads
TzData.Runtime.Linux.AutoInit

Opt-in automatic TZDIR setup for TzData.Runtime.Linux. Injects a module initializer into executable projects (Exe/WinExe) so TzDataRuntime.Configure() runs before Main, and applies the optional build-time default time zone (TzDataRuntimeAutoInitTimeZone). Linux-only; disable with TzDataRuntimeAutoInit=false.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 98 11/21/2026