Chuyển đến nội dung
Skillpedia
Lập trình chung40k · #7180

dotnet-timezone

Skill này làm gì

Công cụ này giúp lập trình viên xử lý múi giờ trong code C# (.NET). Nó cung cấp thông tin về cách chuyển đổi thời gian giữa các địa điểm khác nhau, hiểu về giờ mùa hè và bảo đảm code hoạt động đúng trên các hệ điều hành khác nhau.

Khi nào nên dùng

  • ✓Khi bạn cần biết múi giờ của một thành phố cụ thể.
  • ✓Khi chuyển đổi thời gian giữa UTC và giờ địa phương.
  • ✓Để bảo đảm code hoạt động đúng trên cả máy Windows và Linux.

Liên kết skill

https://github.com/github/awesome-copilot/blob/main/skills/dotnet-timezone/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/dotnet-timezone/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Múi giờ của Tokyo là gì, và cho tôi một ví dụ code C# để chuyển thời gian hiện tại từ UTC sang múi giờ đó.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ tra cứu một chỉ mục múi giờ đã biết và dùng các thư viện .NET để tìm thông tin chính xác. Nó có thể tạo các đoạn code sẵn dùng tùy theo nhu cầu của bạn, như chuyển đổi đơn giản hoặc lập lịch phức tạp.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

.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
Câu hỏi thường gặp

UTC là gì?

UTC (Coordinated Universal Time) là chuẩn thời gian chính mà thế giới dùng để điều chỉnh đồng hồ. Nó giống “Giờ chuẩn Greenwich” (GMT) nhưng chính xác hơn.

Giờ mùa hè (DST) là gì?

DST là khi đồng hồ được điều chỉnh tới trước, thường vào mùa xuân, để tận dụng ánh sáng ban ngày tốt hơn. Không phải nơi nào cũng áp dụng.

Tại sao tôi cần quan tâm đến múi giờ trong code?

Nếu ứng dụng của bạn xử lý ngày và giờ từ nhiều nơi (hoặc ngay cả từ chính bạn), dùng đúng múi giờ là rất quan trọng để tránh lỗi, đặc biệt khi lập lịch hoặc hiển thị thông tin cho người dùng ở các khu vực khác nhau.

Chi tiết

Mô tả gốc của tác giả

.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.

repo: github/awesome-copilot

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7180
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự