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

Side by Side Diff: lib/coreimpl/date.dart

Issue 10964046: migrate raw string to new syntax in core (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class DateImplementation implements Date { 5 class DateImplementation implements Date {
6 final int millisecondsSinceEpoch; 6 final int millisecondsSinceEpoch;
7 final bool isUtc; 7 final bool isUtc;
8 8
9 factory DateImplementation.fromString(String formattedString) { 9 factory DateImplementation.fromString(String formattedString) {
10 // Read in (a subset of) ISO 8601. 10 // Read in (a subset of) ISO 8601.
11 // Examples: 11 // Examples:
12 // - "2012-02-27 13:27:00" 12 // - "2012-02-27 13:27:00"
13 // - "2012-02-27 13:27:00.423z" 13 // - "2012-02-27 13:27:00.423z"
14 // - "20120227 13:27:00" 14 // - "20120227 13:27:00"
15 // - "20120227T132700" 15 // - "20120227T132700"
16 // - "20120227" 16 // - "20120227"
17 // - "2012-02-27T14Z" 17 // - "2012-02-27T14Z"
18 // - "-123450101 00:00:00 Z" // In the year -12345. 18 // - "-123450101 00:00:00 Z" // In the year -12345.
19 final RegExp re = const RegExp( 19 final RegExp re = const RegExp(
20 @'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part. 20 r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part.
21 @'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'); 21 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$');
22 Match match = re.firstMatch(formattedString); 22 Match match = re.firstMatch(formattedString);
23 if (match !== null) { 23 if (match !== null) {
24 int parseIntOrZero(String matched) { 24 int parseIntOrZero(String matched) {
25 // TODO(floitsch): we should not need to test against the empty string. 25 // TODO(floitsch): we should not need to test against the empty string.
26 if (matched === null || matched == "") return 0; 26 if (matched === null || matched == "") return 0;
27 return int.parse(matched); 27 return int.parse(matched);
28 } 28 }
29 29
30 double parseDoubleOrZero(String matched) { 30 double parseDoubleOrZero(String matched) {
31 // TODO(floitsch): we should not need to test against the empty string. 31 // TODO(floitsch): we should not need to test against the empty string.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 external Duration get timeZoneOffset; 176 external Duration get timeZoneOffset;
177 external int get year; 177 external int get year;
178 external int get month; 178 external int get month;
179 external int get day; 179 external int get day;
180 external int get hour; 180 external int get hour;
181 external int get minute; 181 external int get minute;
182 external int get second; 182 external int get second;
183 external int get millisecond; 183 external int get millisecond;
184 external int get weekday; 184 external int get weekday;
185 } 185 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698