-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4010c7
commit 38fcf6a
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
project(tzextract VERSION 1.0.0 LANGUAGES CSharp) | ||
|
||
add_executable(${PROJECT_NAME} | ||
tzextract.cs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Text; | ||
|
||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
Console.WriteLine("/* Automatically generated by tzextract */"); | ||
Console.WriteLine(""); | ||
Console.WriteLine("#include \"TimeZoneNameMap.h\""); | ||
Console.WriteLine(""); | ||
Console.WriteLine("const TimeZoneNameMapEntry TimeZoneNameMap[] ={"); | ||
|
||
foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones()) | ||
{ | ||
string iana; | ||
TimeZoneInfo.TryConvertWindowsIdToIanaId(tz.Id, out iana); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
sb.Append("{ \""); | ||
sb.Append(tz.Id); | ||
sb.Append("\", \""); | ||
sb.Append(tz.StandardName); | ||
sb.Append("\", \""); | ||
sb.Append(tz.DisplayName); | ||
sb.Append("\", \""); | ||
sb.Append(tz.DaylightName); | ||
sb.Append("\", \""); | ||
sb.Append(iana); | ||
sb.Append("\" },"); | ||
Console.WriteLine(sb.ToString()); | ||
} | ||
|
||
Console.WriteLine("};"); | ||
Console.WriteLine(""); | ||
Console.WriteLine("const size_t TimeZoneNameMapSize = ARRAYSIZE(TimeZoneNameMap);"); | ||
Console.WriteLine(""); | ||
} | ||
} |