Generated banner for Dotnet Timezone
Generated logo for Dotnet Timezone

Dotnet Timezone

GitHubOfficialFirst committed by pasindudilshan1Distributed by GitHub

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

.NET timezone handling guidance for C# applications. Use when working with TimeZoneInfo, DateTimeOffset, NodaTime, UTC conversion, daylight saving time, scheduling across timezones, cross-platform Windows/IANA timezone IDs, or when a .NET user needs the timezone for a city, address, region, or country and copy-paste-ready C# code.
— the description by pasindudilshan1

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides developers with production-safe guidance for managing timezones in .NET applications. It covers cross-platform compatibility, conversion between Windows and IANA timezone IDs, and best practices for handling daylight saving time and scheduling. The skill includes a reference index for common timezone mappings and specific code patterns for libraries like TimeZoneConverter and NodaTime.

What it does

  • Resolves timezone IDs for specific cities, regions, or countries.
  • Provides cross-platform C# code snippets for timezone conversion.
  • Maps between Windows and IANA timezone identifiers.
  • Offers patterns for handling daylight saving time and ambiguous timestamps.
  • Recommends appropriate libraries based on project requirements.
  • Warns against common pitfalls like using local time in databases.

When to use it

  • When you need to convert between UTC and local time in a C# application.
  • When building cross-platform .NET apps that must run on both Windows and Linux.
  • When implementing recurring jobs or scheduling logic that respects local timezone rules.
  • When you need to resolve a location to its corresponding Windows and IANA timezone IDs.
  • When dealing with complex timezone arithmetic or DST edge cases.

Advantages

  • Reduces errors by promoting UTC-first storage practices.
  • Simplifies cross-platform development by bridging Windows and IANA ID differences.
  • Provides ready-to-use, copy-pasteable code patterns for common scenarios.
  • Helps avoid common pitfalls like hardcoded offsets or incorrect timestamp handling.

Usage examples

“How do I convert UTC to Tokyo time in a cross-platform .NET app?”
The agent provides a code snippet using the TimeZoneConverter library, showing how to retrieve the Tokyo timezone and perform the conversion.
“What is the IANA ID for Sri Lanka and how do I use it in NodaTime?”
The agent returns the IANA ID (Asia/Colombo) and a NodaTime code example using DateTimeZoneProviders.Tzdb.
“How should I handle recurring jobs across timezones in ASP.NET Core?”
The agent suggests using TimeZoneConverter to translate local time to UTC before scheduling and provides an example using RecurringJobOptions.
“My app is failing on Linux because of Windows timezone IDs. How do I fix this?”
The agent explains the difference between Windows and IANA IDs and recommends using the TimeZoneConverter library to handle the mapping automatically.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/github/dotnet-timezone/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip dotnet-timezone.zip -d .agents/skills

Documentation by pasindudilshan1

.NET Timezone

Resolve timezone questions for .NET and C# code with production-safe guidance and copy-paste-ready snippets.

Start With The Right Path

Identify the request type first:

  • Address or location lookup

  • Timezone ID lookup

  • UTC/local conversion

  • Cross-platform timezone compatibility

  • Scheduling or DST handling

  • API or persistence design

If the library is unclear, default to TimeZoneConverter for cross-platform work. If the scenario involves recurring schedules or strict DST rules, prefer NodaTime.

Resolve Addresses And Locations

If the user provides an address, city, region, country, or document containing place names:

  1. Extract each location from the input.

  2. Read references/timezone-index.md for common Windows and IANA mappings.

  3. If the exact location is not listed, infer the correct IANA zone from geography, then map it to the Windows ID.

  4. Return both IDs and a ready-to-use C# example.

For each resolved location, provide:

Location: <resolved place>
Windows ID: <windows id>
IANA ID: <iana id>
UTC offset: <standard offset and DST offset when relevant>
DST: <yes/no>

Then include a cross-platform snippet like:

using TimeZoneConverter;

TimeZoneInfo tz = TZConvert.GetTimeZoneInfo("Asia/Colombo");
DateTime local = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz);

If multiple locations are present, include one block per location and then a combined multi-timezone snippet.

If a location is ambiguous, list the possible timezone matches and ask the user to choose the correct one.

Look Up Timezone IDs

Use references/timezone-index.md for Windows to IANA mappings.

Always provide both formats:

  • Windows ID for TimeZoneInfo.FindSystemTimeZoneById() on Windows

  • IANA ID for Linux, containers, NodaTime, and TimeZoneConverter

Generate Code

Use references/code-patterns.md and pick the smallest pattern that fits:

  • Pattern 1: TimeZoneInfo for Windows-only code

  • Pattern 2: TimeZoneConverter for cross-platform conversion

  • Pattern 3: NodaTime for strict timezone arithmetic and DST-sensitive scheduling

  • Pattern 4: DateTimeOffset for APIs and data transfer

  • Pattern 5: ASP.NET Core persistence and presentation

  • Pattern 6: recurring jobs and schedulers

  • Pattern 7: ambiguous and invalid DST timestamps

Always include package guidance when recommending third-party libraries.

Warn About Common Pitfalls

Mention the relevant warning when applicable:

  • TimeZoneInfo.FindSystemTimeZoneById() is platform-specific for timezone IDs.

  • Avoid storing DateTime.Now in databases; store UTC instead.

  • Treat DateTimeKind.Unspecified as a bug risk unless it is deliberate input.

  • DST transitions can skip or repeat local times.

  • Azure Windows and Azure Linux environments may expect different timezone ID formats.

Response Shape

For address and location requests:

  1. Return the resolved timezone block for each location.

  2. State the recommended implementation in one sentence.

  3. Include a copy-paste-ready C# snippet.

For code and architecture requests:

  1. State the recommended approach in one sentence.

  2. Provide the timezone IDs if relevant.

  3. Include the minimal working code snippet.

  4. Mention the package requirement if needed.

  5. Add one pitfall warning if it matters.

Keep responses concise and code-first.

References

  • references/timezone-index.md: common Windows and IANA timezone mappings

  • references/code-patterns.md: ready-to-use .NET timezone patterns

Files

references/code-patterns.md

.NET Timezone Code Patterns

Pattern 1: Basic TimeZoneInfo

Use this only when the application is Windows-only and Windows timezone IDs are acceptable.

DateTime utcNow = DateTime.UtcNow;
TimeZoneInfo sriLankaTz = TimeZoneInfo.FindSystemTimeZoneById("Sri Lanka Standard Time");
DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(utcNow, sriLankaTz);

DateTime backToUtc = TimeZoneInfo.ConvertTimeToUtc(localTime, sriLankaTz);

TimeZoneInfo tokyoTz = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
DateTime tokyoTime = TimeZoneInfo.ConvertTime(localTime, sriLankaTz, tokyoTz);

Use TimeZoneConverter or NodaTime instead for Linux, containers, or mixed environments.

Pattern 2: Cross-Platform With TimeZoneConverter

Recommended default for most .NET apps that run across Windows and Linux.

<PackageReference Include="TimeZoneConverter" Version="6.*" />
using TimeZoneConverter;

TimeZoneInfo tz = TZConvert.GetTimeZoneInfo("Asia/Colombo");
DateTime converted = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz);

This also accepts Windows IDs:

TimeZoneInfo tz = TZConvert.GetTimeZoneInfo("Sri Lanka Standard Time");

Pattern 3: NodaTime

Use this for strict timezone arithmetic, recurring schedules, or DST edge cases where correctness matters more than minimal dependencies.

<PackageReference Include="NodaTime" Version="3.*" />
using NodaTime;

DateTimeZone colomboZone = DateTimeZoneProviders.Tzdb["Asia/Colombo"];
Instant now = SystemClock.Instance.GetCurrentInstant();
ZonedDateTime colomboTime = now.InZone(colomboZone);

DateTimeZone tokyoZone = DateTimeZoneProviders.Tzdb["Asia/Tokyo"];
ZonedDateTime tokyoTime = colomboTime.WithZone(tokyoZone);

LocalDateTime localDt = new LocalDateTime(2024, 6, 15, 14, 30, 0);
ZonedDateTime zoned = colomboZone.AtStrictly(localDt);
Instant utcInstant = zoned.ToInstant();

Pattern 4: DateTimeOffset For APIs

Prefer DateTimeOffset for values crossing service or process boundaries.

using TimeZoneConverter;

DateTimeOffset utcNow = DateTimeOffset.UtcNow;
TimeZoneInfo tz = TZConvert.GetTimeZoneInfo("Asia/Colombo");
DateTimeOffset colomboTime = TimeZoneInfo.ConvertTime(utcNow, tz);

Pattern 5: ASP.NET Core Persistence And Presentation

Store UTC, convert at the edges.

using TimeZoneConverter;

entity.CreatedAtUtc = DateTime.UtcNow;

public DateTimeOffset ToUserTime(DateTime utc, string userIanaTimezone)
{
    var tz = TZConvert.GetTimeZoneInfo(userIanaTimezone);
    return TimeZoneInfo.ConvertTimeFromUtc(utc, tz);
}

Pattern 6: Scheduling And Recurring Jobs

Translate a user-facing local time to UTC before scheduling.

using TimeZoneConverter;

TimeZoneInfo tz = TZConvert.GetTimeZoneInfo("Asia/Colombo");
DateTime scheduledLocal = new DateTime(2024, 12, 1, 9, 0, 0, DateTimeKind.Unspecified);
DateTime scheduledUtc = TimeZoneInfo.ConvertTimeToUtc(scheduledLocal, tz);

With Hangfire:

RecurringJob.AddOrUpdate(
    "morning-job",
    () => DoWork(),
    "0 9 * * *",
    new RecurringJobOptions { TimeZone = tz });

Pattern 7: Ambiguous And Invalid DST Times

Check for repeated or skipped local timestamps when the timezone observes daylight saving time.

using TimeZoneConverter;

TimeZoneInfo tz = TZConvert.GetTimeZoneInfo("America/New_York");
DateTime localTime = new DateTime(2024, 11, 3, 1, 30, 0);

if (tz.IsAmbiguousTime(localTime))
{
    var offsets = tz.GetAmbiguousTimeOffsets(localTime);
    var standardOffset = offsets.Min();
    var dto = new DateTimeOffset(localTime, standardOffset);
}

if (tz.IsInvalidTime(localTime))
{
    localTime = localTime.AddHours(1);
}

Common Mistakes

WrongBetter
DateTime.Now in server codeDateTime.UtcNow
Storing local timestamps in the databaseStore UTC and convert for display
Hardcoding offsets such as +05:30Use timezone IDs
Using FindSystemTimeZoneById("Asia/Colombo") on WindowsUse TZConvert.GetTimeZoneInfo("Asia/Colombo")
Comparing local DateTime values from different zonesCompare UTC or use DateTimeOffset
Creating DateTime without intentional kind semanticsUse Utc, Local, or deliberate Unspecified

Decision Guide

  • Use TimeZoneInfo only for Windows-only code with Windows IDs.

  • Use TimeZoneConverter for most cross-platform applications.

  • Use NodaTime when DST arithmetic or calendaring accuracy is central.

  • Use DateTimeOffset for APIs and serialized timestamps.

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of pasindudilshan1pasindudilshan1
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/dotnet-timezone · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
pasindudilshan1

AutoGineer is not affiliated with or endorsed by pasindudilshan1 or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download dotnet-timezone.zip