Chromium Code Reviews| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 /** | 187 /** |
| 188 * Constructs a new [DateTime] instance with current date time value in the | 188 * Constructs a new [DateTime] instance with current date time value in the |
| 189 * local time zone. | 189 * local time zone. |
| 190 */ | 190 */ |
| 191 // TODO(8042): This should be a redirecting constructor and not a factory. | 191 // TODO(8042): This should be a redirecting constructor and not a factory. |
| 192 factory DateTime.now() { return new DateTime._now(); } | 192 factory DateTime.now() { return new DateTime._now(); } |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * Constructs a new [DateTime] instance based on [formattedString]. | 195 * Constructs a new [DateTime] instance based on [formattedString]. |
| 196 * | 196 * |
| 197 * The function parses a subset of ISO 8601. Examples of accepted strings: | 197 * The function parses a subset of ISO 8601. Examples of accepted strings: |
|
Lasse Reichstein Nielsen
2013/01/24 07:04:24
Can't we do better than examples, e.g., give a gra
floitsch
2013/01/24 12:20:26
Added a TODO. I completely agree, but I don't have
| |
| 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 static DateTime parse(String formattedString) { |
| 209 // Read in (a subset of) ISO 8601. | 209 // Read in (a subset of) ISO 8601. |
| 210 // Examples: | 210 // Examples: |
| 211 // - "2012-02-27 13:27:00" | 211 // - "2012-02-27 13:27:00" |
|
Lasse Reichstein Nielsen
2013/01/24 07:04:24
Remove this comment if it's duplicated in the meth
floitsch
2013/01/24 12:20:26
Done.
| |
| 212 // - "2012-02-27 13:27:00.423z" | 212 // - "2012-02-27 13:27:00.423z" |
| 213 // - "20120227 13:27:00" | 213 // - "20120227 13:27:00" |
| 214 // - "20120227T132700" | 214 // - "20120227T132700" |
| 215 // - "20120227" | 215 // - "20120227" |
| 216 // - "2012-02-27T14Z" | 216 // - "2012-02-27T14Z" |
| 217 // - "-123450101 00:00:00 Z" // In the year -12345. | 217 // - "-123450101 00:00:00 Z" // In the year -12345. |
| 218 final RegExp re = new RegExp( | 218 final RegExp re = new RegExp( |
| 219 r'^([+-]?\d?\d\d\d\d)-?(\d\d)-?(\d\d)' // The day part. | 219 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])?)?$'); | 220 r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(.\d{1,6})?)?)? ?([zZ])?)?$'); |
| 221 Match match = re.firstMatch(formattedString); | 221 Match match = re.firstMatch(formattedString); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 * Returns the millisecond into the second [0...999]. | 477 * Returns the millisecond into the second [0...999]. |
| 478 */ | 478 */ |
| 479 external int get millisecond; | 479 external int get millisecond; |
| 480 | 480 |
| 481 /** | 481 /** |
| 482 * Returns the week day [MON..SUN]. In accordance with ISO 8601 | 482 * Returns the week day [MON..SUN]. In accordance with ISO 8601 |
| 483 * a week starts with Monday which has the value 1. | 483 * a week starts with Monday which has the value 1. |
| 484 */ | 484 */ |
| 485 external int get weekday; | 485 external int get weekday; |
| 486 } | 486 } |
| OLD | NEW |