Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Unified Diff: sdk/lib/core/date_time.dart

Issue 48823005: improve DateTime parsing a UTC timezone offset (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/corelib/date_time_parse_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/date_time.dart
diff --git a/sdk/lib/core/date_time.dart b/sdk/lib/core/date_time.dart
index 0b4a63a19a0c63eb8fe2baa877c109c800b595a6..566260607c1c566f0670e58e90bc2377bde162a3 100644
--- a/sdk/lib/core/date_time.dart
+++ b/sdk/lib/core/date_time.dart
@@ -48,7 +48,7 @@ part of dart.core;
* unless explicitly created in the UTC time zone.
*
* DateTime dDay = new DateTime.utc(1944, 6, 6);
- *
+ *
* Use [isUtc] to determine whether a DateTime object is based in UTC.
* Use the methods [toLocal] and [toUtc]
* to get the equivalent date/time value specified in the other time zone.
@@ -199,13 +199,14 @@ class DateTime implements Comparable {
* * `"20120227"`
* * `"+20120227"`
* * `"2012-02-27T14Z"`
+ * * `"2012-02-27T14+00:00"`
* * `"-123450101 00:00:00 Z"`: in the year -12345.
*/
// TODO(floitsch): specify grammar.
static DateTime parse(String formattedString) {
final RegExp re = new RegExp(
r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part.
- r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$');
+ r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ]|(\+00(:?00)?)?))?$');
floitsch 2013/10/28 23:01:24 80 chars. The "(\+00" should be a non-capturing ("
Match match = re.firstMatch(formattedString);
if (match != null) {
int parseIntOrZero(String matched) {
« no previous file with comments | « no previous file | tests/corelib/date_time_parse_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698