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

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

Issue 12047046: Change new DateTime.fromString to DateTime.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 11 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 | « samples/chat/dart_client/chat.dart ('k') | tests/corelib/date_time2_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 b994e4ba6659b9b7fcf5ddd2c8ea31e03594fbf7..92321f63b730c444191c1792095f582c77b7c35f 100644
--- a/sdk/lib/core/date_time.dart
+++ b/sdk/lib/core/date_time.dart
@@ -56,7 +56,7 @@ abstract class Date implements Comparable {
factory Date.now() => new DateTime.now();
factory Date.fromString(String formattedString)
- => new DateTime.fromString(formattedString);
+ => DateTime.parse(formattedString);
factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
{bool isUtc: false}) {
@@ -205,16 +205,8 @@ class DateTime implements Date {
* * `"2012-02-27T14Z"`
* * `"-123450101 00:00:00 Z"`: in the year -12345.
*/
- factory DateTime.fromString(String formattedString) {
- // Read in (a subset of) ISO 8601.
- // Examples:
- // - "2012-02-27 13:27:00"
- // - "2012-02-27 13:27:00.423z"
- // - "20120227 13:27:00"
- // - "20120227T132700"
- // - "20120227"
- // - "2012-02-27T14Z"
- // - "-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])?)?$');
« no previous file with comments | « samples/chat/dart_client/chat.dart ('k') | tests/corelib/date_time2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698