2 Star 0 Fork 0

ploughmal/FlipIt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
GenerateFlipItTimeZoneCities.linq 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
phaselden 提交于 2021-01-26 18:21 . Improvements to the WorldTime screen
<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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ploughmal/FlipIt.git
git@gitee.com:ploughmal/FlipIt.git
ploughmal
FlipIt
FlipIt
master

搜索帮助