Merge pull request #900 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / class / corlib / System / DateTime.cs
index 68bf2e793311530b9feea5d517d113706d99c453..766b71962095d42361b9739a0b8637cc12a86ec6 100644 (file)
@@ -376,7 +376,7 @@ namespace System
                DateTime (SerializationInfo info, StreamingContext context)
                {
                        if (info.HasKey ("dateData")){
-                               encoded = info.GetInt64 ("dateData");
+                               encoded = (Int64)info.GetUInt64 ("dateData");
                        } else if (info.HasKey ("ticks")){
                                encoded = info.GetInt64 ("ticks") & TicksMask;
                        } else {
@@ -470,7 +470,7 @@ namespace System
                                long now = GetNow ();
                                DateTime dt = new DateTime (now);
 
-                               if ((now - last_now) > TimeSpan.TicksPerMinute){
+                               if (Math.Abs (now - last_now) > TimeSpan.TicksPerMinute){
                                        to_local_time_span_object = TimeZone.CurrentTimeZone.GetLocalTimeDiff (dt);
                                        last_now = now;
 
@@ -1046,7 +1046,7 @@ namespace System
                        if (maxlength <= 0)
                                maxlength = value.Length;
 
-                       if (sPos + maxlength <= s.Length && String.Compare (s, sPos, value, 0, maxlength, true, CultureInfo.InvariantCulture) == 0) {
+                       if (sPos + maxlength <= s.Length && String.CompareOrdinalCaseInsensitive (s, sPos, value, 0, maxlength) == 0) {
                                num_parsed = maxlength;
                                return true;
                        }
@@ -1588,7 +1588,7 @@ namespace System
                                        // '.FFF....' can be mapped to nothing
                                        if (pos + 1 < len && chars[pos + 1] == 'F') {
                                                ++pos;
-                                               while (pos < len && chars[pos + 1] == 'F') {
+                                               while (pos + 1 < len && chars[pos + 1] == 'F') {
                                                        ++pos;
                                                }
 
@@ -1805,7 +1805,7 @@ namespace System
                        {
                                if ((style & DateTimeStyles.AdjustToUniversal) != 0 || (style & DateTimeStyles.AssumeLocal) != 0 ||
                                         (style & DateTimeStyles.AssumeUniversal) != 0)
-                                       throw new ArgumentException ("The DateTimeStyles value RoundtripKind cannot be used with the values AssumeLocal, Asersal or AdjustToUniversal.", "style");
+                                       throw new ArgumentException ("The DateTimeStyles value RoundtripKind cannot be used with the values AssumeLocal, AssumeUniversal or AdjustToUniversal.", "style");
                        }
                        if ((style & DateTimeStyles.AssumeUniversal) != 0 && (style & DateTimeStyles.AssumeLocal) != 0)                 
                                throw new ArgumentException ("The DateTimeStyles values AssumeLocal and AssumeUniversal cannot be used together.", "style");
@@ -2003,10 +2003,9 @@ namespace System
                        if (format == null || format == String.Empty)
                                format = "G";
 
-                       bool useutc = false, use_invariant = false;
-
                        if (format.Length == 1) {
                                char fchar = format [0];
+                               bool use_invariant, useutc;
                                format = DateTimeUtils.GetStandardPattern (fchar, dfi, out useutc, out use_invariant);
                                if (fchar == 'U')
                                        return DateTimeUtils.ToString (ToUniversalTime (), format, dfi);
@@ -2014,6 +2013,9 @@ namespace System
 
                                if (format == null)
                                        throw new FormatException ("format is not one of the format specifier characters defined for DateTimeFormatInfo");
+
+                               if (use_invariant)
+                                       dfi = DateTimeFormatInfo.InvariantInfo;
                        }
 
                        // Don't convert UTC value. It just adds 'Z' for 
@@ -2186,7 +2188,7 @@ namespace System
                        info.AddValue ("ticks", t);
 
                        // This is the new .NET format, encodes the kind on the top bits
-                       info.AddValue ("dateData", encoded);
+                       info.AddValue ("dateData", (UInt64)encoded);
                }
                
 #if MONOTOUCH