#if !MONODROID && !MONOTOUCH && !XAMMAC
static TimeZoneInfo CreateLocal ()
{
-#if !FULL_AOT_DESKTOP || WIN_PLATFORM
+#if WIN_PLATFORM
if (IsWindows && LocalZoneKey != null) {
string name = (string)LocalZoneKey.GetValue ("TimeZoneKeyName");
if (name == null)
static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
{
-#if !FULL_AOT_DESKTOP || WIN_PLATFORM
+#if WIN_PLATFORM
if (TimeZoneKey != null) {
foreach (string id in TimeZoneKey.GetSubKeyNames ()) {
try {
#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>
return str.Substring (Istart, Iend-Istart+1);
}
-
+
#if !FULL_AOT_DESKTOP || WIN_PLATFORM
static RegistryKey timeZoneKey;
static RegistryKey TimeZoneKey {
#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
else
ParseRegTzi(adjustmentRules, 1, 9999, reg_tzi);
- return CreateCustomTimeZone (id, baseUtcOffset, display_name, standard_name, daylight_name, ValidateRules (adjustmentRules).ToArray ());
+ return CreateCustomTimeZone (id, baseUtcOffset, display_name, standard_name, daylight_name, ValidateRules (adjustmentRules));
}
private static void ParseRegTzi (List<AdjustmentRule> adjustmentRules, int start_year, int end_year, byte [] buffer)
return new DateTime (year, transition.Month, day) + transition.TimeOfDay.TimeOfDay;
}
- static List<AdjustmentRule> ValidateRules (List<AdjustmentRule> adjustmentRules)
+ static AdjustmentRule[] ValidateRules (List<AdjustmentRule> adjustmentRules)
{
+ if (adjustmentRules == null || adjustmentRules.Count == 0)
+ return null;
+
AdjustmentRule prev = null;
foreach (AdjustmentRule current in adjustmentRules.ToArray ()) {
if (prev != null && prev.DateEnd > current.DateStart) {
}
prev = current;
}
- return adjustmentRules;
+ return adjustmentRules.ToArray ();
}
#if LIBC || MONOTOUCH
}
tz = CreateCustomTimeZone (id, baseUtcOffset, id, standardDisplayName);
} else {
- tz = CreateCustomTimeZone (id, baseUtcOffset, id, standardDisplayName, daylightDisplayName, ValidateRules (adjustmentRules).ToArray ());
+ tz = CreateCustomTimeZone (id, baseUtcOffset, id, standardDisplayName, daylightDisplayName, ValidateRules (adjustmentRules));
}
if (storeTransition && transitions.Count > 0) {
tz.transitions = transitions;
- tz.supportsDaylightSavingTime = true;
}
+ tz.supportsDaylightSavingTime = adjustmentRules.Count > 0;
return tz;
}