Expand system time selection logic

This commit is contained in:
Ske
2019-06-13 23:42:39 +02:00
parent 72cb838ad7
commit cd9a3e0abd
5 changed files with 164 additions and 2 deletions

View File

@@ -194,6 +194,23 @@ namespace PluralKit
// Still haven't parsed something, we just give up lmao
return null;
}
public static string ExtractCountryFlag(string flag)
{
if (flag.Length != 4) return null;
try
{
var cp1 = char.ConvertToUtf32(flag, 0);
var cp2 = char.ConvertToUtf32(flag, 2);
if (cp1 < 0x1F1E6 || cp1 > 0x1F1FF) return null;
if (cp2 < 0x1F1E6 || cp2 > 0x1F1FF) return null;
return $"{(char) (cp1 - 0x1F1E6 + 'A')}{(char) (cp2 - 0x1F1E6 + 'A')}";
}
catch (ArgumentException)
{
return null;
}
}
}
public static class Emojis {