| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart core library. | 5 // Dart core library. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Date is the public interface to a point in time. | 8 * Date is the public interface to a point in time. |
| 9 * | 9 * |
| 10 * It can represent time values that are at a distance of at most | 10 * It can represent time values that are at a distance of at most |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 factory _DateImpl.fromString(String formattedString) { | 250 factory _DateImpl.fromString(String formattedString) { |
| 251 // Read in (a subset of) ISO 8601. | 251 // Read in (a subset of) ISO 8601. |
| 252 // Examples: | 252 // Examples: |
| 253 // - "2012-02-27 13:27:00" | 253 // - "2012-02-27 13:27:00" |
| 254 // - "2012-02-27 13:27:00.423z" | 254 // - "2012-02-27 13:27:00.423z" |
| 255 // - "20120227 13:27:00" | 255 // - "20120227 13:27:00" |
| 256 // - "20120227T132700" | 256 // - "20120227T132700" |
| 257 // - "20120227" | 257 // - "20120227" |
| 258 // - "2012-02-27T14Z" | 258 // - "2012-02-27T14Z" |
| 259 // - "-123450101 00:00:00 Z" // In the year -12345. | 259 // - "-123450101 00:00:00 Z" // In the year -12345. |
| 260 final RegExp re = new RegExp( | 260 final RegExp re = const RegExp( |
| 261 r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part. | 261 r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part. |
| 262 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'); | 262 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'); |
| 263 Match match = re.firstMatch(formattedString); | 263 Match match = re.firstMatch(formattedString); |
| 264 if (match != null) { | 264 if (match != null) { |
| 265 int parseIntOrZero(String matched) { | 265 int parseIntOrZero(String matched) { |
| 266 // TODO(floitsch): we should not need to test against the empty string. | 266 // TODO(floitsch): we should not need to test against the empty string. |
| 267 if (matched == null || matched == "") return 0; | 267 if (matched == null || matched == "") return 0; |
| 268 return int.parse(matched); | 268 return int.parse(matched); |
| 269 } | 269 } |
| 270 | 270 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 external Duration get timeZoneOffset; | 419 external Duration get timeZoneOffset; |
| 420 external int get year; | 420 external int get year; |
| 421 external int get month; | 421 external int get month; |
| 422 external int get day; | 422 external int get day; |
| 423 external int get hour; | 423 external int get hour; |
| 424 external int get minute; | 424 external int get minute; |
| 425 external int get second; | 425 external int get second; |
| 426 external int get millisecond; | 426 external int get millisecond; |
| 427 external int get weekday; | 427 external int get weekday; |
| 428 } | 428 } |
| OLD | NEW |