Merge pull request #1266 from esdrubal/datetimenewformat
[mono.git] / mcs / class / corlib / System / DateTime.cs
index 735599680c52f26706f02cd504f95d55bf76ba60..272f6996191aca2720a7537ada49959ed392fedc 100644 (file)
@@ -108,6 +108,7 @@ namespace System
                        "H:m",
                        "H tt", // Specifies AM to disallow '8'.
                        "H'\u6642'm'\u5206's'\u79D2'",
+                       "zzz"
                };
 
                // DateTime.Parse date patterns extend ParseExact patterns as follows:
@@ -1466,6 +1467,25 @@ namespace System
                                        if (num_parsed == -1)
                                                return false;
                                        fractionalSeconds = decimalNumber / Math.Pow(10.0, num_parsed);
+
+                                       //Parse ISO8601 with an unlimited number of fractional digits.
+                                       if (!exact && num == 6 && hour != -1 && minute != -1 && second != -1) {
+                                               var total_num_parsed = num_parsed;
+                                               while (true) {
+                                                       valuePos += num_parsed;
+                                                       decimalNumber = (double) _ParseNumber (s, valuePos, 0, 1, leading_zeros, sloppy_parsing, out num_parsed);
+                                                       if (num_parsed < 1) {
+                                                               num_parsed = 0;
+                                                               break;
+                                                       }
+
+                                                       total_num_parsed += num_parsed;
+                                                       if (total_num_parsed > 15)
+                                                               continue; //not enough precision, ignore additional digits.
+
+                                                       fractionalSeconds += decimalNumber / Math.Pow (10.0, total_num_parsed);
+                                               }
+                                       }
                                        break;
                                case 't':
                                        if (!_ParseAmPm (s, valuePos, num > 0 ? 0 : 1, dfi, exact, out num_parsed, ref ampm))