Reviewed by 20X · No signed release verified
- Works with (as stated by the author)
- GitHub Copilot
Review details
- Human review
- Review recorded for these files
- Limited checks
- Limited checks recorded (v2.1.0)
- Source
- Source not verified
A verified signature checks published file bytes against a trusted publisher’s signed manifest. It does not verify safety, authorship, rights or assistant use.
Declarations and limited checks do not guarantee safety or sharing rights. Review the files before use. Access that the author has not stated is unknown.
How to use it
- 1Download the skill folder and keep its files together.
- 2Put the folder in your agent's skills directory (for Claude Code: ~/.claude/skills/ or .claude/skills/ in a project), or upload it as a skill in the Claude app.
- 3Start a new session so the skill is picked up.
- 4Ask the agent for help with time zones in .NET.
Community results
0 reportsNo one has shared a result yet.
3 files. Filenames and raw files are in Technical details.
.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
| Wrong | Better |
|---|---|
DateTime.Now in server code | DateTime.UtcNow |
| Storing local timestamps in the database | Store UTC and convert for display |
Hardcoding offsets such as +05:30 | Use timezone IDs |
Using FindSystemTimeZoneById("Asia/Colombo") on Windows | Use TZConvert.GetTimeZoneInfo("Asia/Colombo") |
Comparing local DateTime values from different zones | Compare UTC or use DateTimeOffset |
Creating DateTime without intentional kind semantics | Use Utc, Local, or deliberate Unspecified |
Decision Guide
- Use
TimeZoneInfoonly for Windows-only code with Windows IDs. - Use
TimeZoneConverterfor most cross-platform applications. - Use
NodaTimewhen DST arithmetic or calendaring accuracy is central. - Use
DateTimeOffsetfor APIs and serialized timestamps.
Latest changes
Initial reviewed release.
Version history
v1.0.0
Initial reviewed release.
File access pausedFile verification
- File integrity
No signed release verified for this version.
This checks published bytes, not safety, authorship, rights or assistant use.
Full compatibility
As stated by the author: GitHub Copilot
Included files
3 filesreferences/code-patterns.md
markdownreferences/timezone-index.md
markdownSKILL.md
markdownPublic file access is temporarily paused.
Use in your own tool
Save this resource and connect your assistant in the Use with flow before copying a test request.
Related resources
C# XML Documentation Comments
Ensures C# types are documented with XML comments that follow best practice.
GitHub Copilot
- Rating
- Not rated
- Recorded downloads in the past 90 days
- 0
- Updated
- Nov 11
Writing Instructions for AI Agents
Guidance for writing skills, AGENTS.md, and CLAUDE.md files that AI agents actually follow.
Claude Code
- Rating
- Not rated
- Recorded downloads in the past 90 days
- 0
- Updated
- Nov 11
Context Engineering Setup (Addy Osmani)
Optimises agent context setup: when to start fresh, configure rules files, and recover degraded output quality.
Claude Code
- Rating
- Not rated
- Recorded downloads in the past 90 days
- 0
- Updated
- Nov 11