static TimeZoneInfo CreateLocal ()
{
#if !FULL_AOT_DESKTOP
if (IsWindows && LocalZoneKey != null) {
string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName");
if (name == null)
name = (string)LocalZoneKey.GetValue ("StandardName"); // windows xp
name = TrimSpecial (name);
if (name != null)
return TimeZoneInfo.FindSystemTimeZoneById (name);
}
#endif
var tz = Environment.GetEnvironmentVariable ("TZ");
if (tz != null) {
if (tz == String.Empty)
return Utc;
try {
return FindSystemTimeZoneByFileName (tz, Path.Combine (TimeZoneDirectory, tz));
} catch {
return Utc;
}
}
var tzFilePaths = new string [] {
"/etc/localtime",
Path.Combine (TimeZoneDirectory, "localtime")};
foreach (var tzFilePath in tzFilePaths) {
try {
string tzName = null;
if (!TryGetNameFromPath (tzFilePath, out tzName))
tzName = "Local";
return FindSystemTimeZoneByFileName (tzName, tzFilePath);
} catch (TimeZoneNotFoundException) {
continue;
}
}
return Utc;
}