Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@ -152,7 +152,7 @@ namespace System
#if !MONODROID && !MONOTOUCH && !XAMMAC
static TimeZoneInfo CreateLocal ()
{
#if !FULL_AOT_DESKTOP || WIN_PLATFORM
#if (!FULL_AOT_DESKTOP || WIN_PLATFORM) && !XAMMAC_4_5
if (IsWindows && LocalZoneKey != null) {
string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName");
if (name == null)
@ -160,6 +160,8 @@ namespace System
name = TrimSpecial (name);
if (name != null)
return TimeZoneInfo.FindSystemTimeZoneById (name);
} else if (IsWindows) {
return GetLocalTimeZoneInfoWinRTFallback ();
}
#endif
@ -204,7 +206,7 @@ namespace System
static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
{
#if !FULL_AOT_DESKTOP || WIN_PLATFORM
#if (!FULL_AOT_DESKTOP || WIN_PLATFORM) && !XAMMAC_4_5
if (TimeZoneKey != null) {
foreach (string id in TimeZoneKey.GetSubKeyNames ()) {
try {
@ -212,6 +214,9 @@ namespace System
} catch {}
}
return;
} else if (IsWindows) {
systemTimeZones.AddRange (GetSystemTimeZonesWinRTFallback ());
return;
}
#endif
@ -273,7 +278,7 @@ namespace System
#endif
private AdjustmentRule [] adjustmentRules;
#if !MOBILE || !FULL_AOT_DESKTOP || WIN_PLATFORM
#if (!MOBILE || !FULL_AOT_DESKTOP || WIN_PLATFORM) && !XAMMAC_4_5
/// <summary>
/// Determine whether windows of not (taken Stephane Delcroix's code)
/// </summary>
@ -300,7 +305,7 @@ namespace System
return str.Substring (Istart, Iend-Istart+1);
}
#if !FULL_AOT_DESKTOP || WIN_PLATFORM
static RegistryKey timeZoneKey;
static RegistryKey TimeZoneKey {
@ -310,9 +315,13 @@ namespace System
if (!IsWindows)
return null;
return timeZoneKey = Registry.LocalMachine.OpenSubKey (
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
false);
try {
return timeZoneKey = Registry.LocalMachine.OpenSubKey (
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
false);
} catch {
return null;
}
}
}
@ -325,8 +334,12 @@ namespace System
if (!IsWindows)
return null;
return localZoneKey = Registry.LocalMachine.OpenSubKey (
"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", false);
try {
return localZoneKey = Registry.LocalMachine.OpenSubKey (
"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", false);
} catch {
return null;
}
}
}
#endif
@ -547,6 +560,8 @@ namespace System
if (key == null)
throw new TimeZoneNotFoundException ();
return FromRegistryKey(id, key);
} else if (IsWindows) {
return FindSystemTimeZoneByIdWinRTFallback (id);
}
#endif
// Local requires special logic that already exists in the Local property (bug #326)
@ -559,11 +574,17 @@ namespace System
#if LIBC
private static TimeZoneInfo FindSystemTimeZoneByFileName (string id, string filepath)
{
if (!File.Exists (filepath))
throw new TimeZoneNotFoundException ();
using (FileStream stream = File.OpenRead (filepath)) {
FileStream stream = null;
try {
stream = File.OpenRead (filepath);
} catch (Exception ex) {
throw new TimeZoneNotFoundException ("Couldn't read time zone file " + filepath, ex);
}
try {
return BuildFromStream (id, stream);
} finally {
if (stream != null)
stream.Dispose();
}
}
#endif
@ -811,7 +832,7 @@ namespace System
return tz.BaseUtcOffset;
}
if (tzRule != null && tz.IsInDST (tzRule, stdUtcDateTime)) {
if (tzRule != null && tz.IsInDST (tzRule, dateTime)) {
// Replicate what .NET does when given a time which falls into the hour which is lost when
// DST starts. isDST should always be true but the offset should be BaseUtcOffset without the
// DST delta while in that hour.
@ -868,7 +889,7 @@ namespace System
AdjustmentRule rule = GetApplicableRule (dateTime);
if (rule != null) {
DateTime tpoint = TransitionPoint (rule.DaylightTransitionEnd, dateTime.Year);
if (dateTime > tpoint - rule.DaylightDelta && dateTime <= tpoint)
if (dateTime > tpoint - rule.DaylightDelta && dateTime <= tpoint)
return true;
}
@ -898,7 +919,6 @@ namespace System
DST_start -= BaseUtcOffset;
DST_end -= (BaseUtcOffset + rule.DaylightDelta);
}
return (dateTime >= DST_start && dateTime < DST_end);
}
@ -1184,31 +1204,16 @@ namespace System
return false;
}
var inDelta = false;
for (var i = transitions.Count - 1; i >= 0; i--) {
var pair = transitions [i];
DateTime ttime = pair.Key;
TimeType ttype = pair.Value;
var delta = new TimeSpan (0, 0, ttype.Offset) - BaseUtcOffset;
if ((ttime + delta) > date) {
inDelta = ttime <= date;
continue;
AdjustmentRule current = GetApplicableRule(date);
if (current != null) {
DateTime tStart = TransitionPoint(current.DaylightTransitionStart, date.Year);
DateTime tEnd = TransitionPoint(current.DaylightTransitionEnd, date.Year);
if ((date >= tStart) && (date <= tEnd)) {
offset = baseUtcOffset + current.DaylightDelta;
isDst = true;
return true;
}
offset = new TimeSpan (0, 0, ttype.Offset);
if (inDelta) {
// Replicate what .NET does when given a time which falls into the hour which is lost when
// DST starts. isDST should be true but the offset should be the non-DST offset.
isDst = transitions [i - 1].Value.IsDst;
} else {
isDst = ttype.IsDst;
}
return true;
}
return false;
}
@ -1498,7 +1503,7 @@ namespace System
if (zone.IsAmbiguousTime (time)) {
isAmbiguousLocalDst = true;
return baseOffset;
// return baseOffset;
}
return zone.GetUtcOffset (time, out isDaylightSavings);