代码拉取完成,页面将自动刷新
<Query Kind="Program">
<DisableMyExtensions>true</DisableMyExtensions>
</Query>
void Main()
{
var timeZones = new List<TimeZone>();
var xml = XDocument.Load(@"C:\dev\FlipIt other\windowsZones.xml");
var version = xml.Descendants("mapTimezones").Attributes("typeVersion").First().Value;
var mapZoneElements = from c in xml.Root.Descendants("mapZone")
select c;
foreach (var e in mapZoneElements)
{
var timeZoneID = e.Attribute("other").Value;
var timeZone = timeZones.SingleOrDefault(t => t.TimeZoneID == timeZoneID);
if (timeZone == null)
{
timeZone = new TimeZone {TimeZoneID = timeZoneID };
timeZones.Add(timeZone);
}
var typeAttribute = e.Attribute("type").Value;
var potentialNames = typeAttribute.Split(" ");
foreach (var potentialName in potentialNames)
{
var name = CleanName(potentialName);
if (!timeZone.Cities.Contains(name))
{
timeZone.Cities.Add(name);
}
}
}
Console.WriteLine($"; Generated by GenerateFlipItTimeZoneCities.linq using https://github.com/unicode-org/cldr/blob/master/common/supplemental/windowsZones.xml version {version}");
foreach (var timeZone in timeZones)
{
Console.WriteLine($"{timeZone.TimeZoneID}={String.Join(',', timeZone.Cities)}");
}
}
string CleanName(string s)
{
var i = s.LastIndexOf('/');
if (i == -1)
return s;
return s.Substring(i+1).Replace('_', ' ');
}
class TimeZone
{
public string TimeZoneID { get; set; }
public List<string> Cities { get; } = new List<string>();
}
// You can define other methods, fields, classes and namespaces here
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。