| 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Deprecated class. Please use [DateTime] instead. | 8 * Deprecated class. Please use [DateTime] instead. |
| 9 */ | 9 */ |
| 10 abstract class Date implements Comparable { | 10 abstract class Date implements Comparable { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 int minute = 0, | 49 int minute = 0, |
| 50 int second = 0, | 50 int second = 0, |
| 51 int millisecond = 0]) { | 51 int millisecond = 0]) { |
| 52 return | 52 return |
| 53 new DateTime.utc(year, month, day, hour, minute, second, millisecond); | 53 new DateTime.utc(year, month, day, hour, minute, second, millisecond); |
| 54 } | 54 } |
| 55 | 55 |
| 56 factory Date.now() => new DateTime.now(); | 56 factory Date.now() => new DateTime.now(); |
| 57 | 57 |
| 58 factory Date.fromString(String formattedString) | 58 factory Date.fromString(String formattedString) |
| 59 => new DateTime.fromString(formattedString); | 59 => DateTime.parse(formattedString); |
| 60 | 60 |
| 61 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, | 61 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, |
| 62 {bool isUtc: false}) { | 62 {bool isUtc: false}) { |
| 63 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, | 63 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, |
| 64 isUtc: isUtc); | 64 isUtc: isUtc); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool operator ==(DateTime other); | 67 bool operator ==(DateTime other); |
| 68 bool operator <(DateTime other); | 68 bool operator <(DateTime other); |
| 69 bool operator <=(DateTime other); | 69 bool operator <=(DateTime other); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 * | 198 * |
| 199 * * `"2012-02-27 13:27:00"` | 199 * * `"2012-02-27 13:27:00"` |
| 200 * * `"2012-02-27 13:27:00.123456z"` | 200 * * `"2012-02-27 13:27:00.123456z"` |
| 201 * * `"20120227 13:27:00"` | 201 * * `"20120227 13:27:00"` |
| 202 * * `"20120227T132700"` | 202 * * `"20120227T132700"` |
| 203 * * `"20120227"` | 203 * * `"20120227"` |
| 204 * * `"+20120227"` | 204 * * `"+20120227"` |
| 205 * * `"2012-02-27T14Z"` | 205 * * `"2012-02-27T14Z"` |
| 206 * * `"-123450101 00:00:00 Z"`: in the year -12345. | 206 * * `"-123450101 00:00:00 Z"`: in the year -12345. |
| 207 */ | 207 */ |
| 208 factory DateTime.fromString(String formattedString) { | 208 // TODO(floitsch): specify grammar. |
| 209 // Read in (a subset of) ISO 8601. | 209 static DateTime parse(String formattedString) { |
| 210 // Examples: | |
| 211 // - "2012-02-27 13:27:00" | |
| 212 // - "2012-02-27 13:27:00.423z" | |
| 213 // - "20120227 13:27:00" | |
| 214 // - "20120227T132700" | |
| 215 // - "20120227" | |
| 216 // - "2012-02-27T14Z" | |
| 217 // - "-123450101 00:00:00 Z" // In the year -12345. | |
| 218 final RegExp re = new RegExp( | 210 final RegExp re = new RegExp( |
| 219 r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part. | 211 r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part. |
| 220 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'); | 212 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'); |
| 221 Match match = re.firstMatch(formattedString); | 213 Match match = re.firstMatch(formattedString); |
| 222 if (match != null) { | 214 if (match != null) { |
| 223 int parseIntOrZero(String matched) { | 215 int parseIntOrZero(String matched) { |
| 224 if (matched == null) return 0; | 216 if (matched == null) return 0; |
| 225 return int.parse(matched); | 217 return int.parse(matched); |
| 226 } | 218 } |
| 227 | 219 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 * Returns the millisecond into the second [0...999]. | 467 * Returns the millisecond into the second [0...999]. |
| 476 */ | 468 */ |
| 477 external int get millisecond; | 469 external int get millisecond; |
| 478 | 470 |
| 479 /** | 471 /** |
| 480 * Returns the week day [MON..SUN]. In accordance with ISO 8601 | 472 * Returns the week day [MON..SUN]. In accordance with ISO 8601 |
| 481 * a week starts with Monday which has the value 1. | 473 * a week starts with Monday which has the value 1. |
| 482 */ | 474 */ |
| 483 external int get weekday; | 475 external int get weekday; |
| 484 } | 476 } |
| OLD | NEW |