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 * An instant in time, such as July 20, 1969, 8:18pm GMT. | 8 * An instant in time, such as July 20, 1969, 8:18pm GMT. |
| 9 * | 9 * |
| 10 * Create a DateTime object by using one of the constructors | 10 * Create a DateTime object by using one of the constructors |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 {bool isUtc: false}) | 360 {bool isUtc: false}) |
| 361 : this.millisecondsSinceEpoch = millisecondsSinceEpoch, | 361 : this.millisecondsSinceEpoch = millisecondsSinceEpoch, |
| 362 this.isUtc = isUtc { | 362 this.isUtc = isUtc { |
| 363 if (millisecondsSinceEpoch.abs() > _MAX_MILLISECONDS_SINCE_EPOCH) { | 363 if (millisecondsSinceEpoch.abs() > _MAX_MILLISECONDS_SINCE_EPOCH) { |
| 364 throw new ArgumentError(millisecondsSinceEpoch); | 364 throw new ArgumentError(millisecondsSinceEpoch); |
| 365 } | 365 } |
| 366 if (isUtc == null) throw new ArgumentError(isUtc); | 366 if (isUtc == null) throw new ArgumentError(isUtc); |
| 367 } | 367 } |
| 368 | 368 |
| 369 /** | 369 /** |
| 370 * Replaces specific parts of a date or time while keeping the rest. | |
| 371 * | |
| 372 * Equivalent to createing a new `DateTime` using `new DateTime` | |
|
sra1
2015/11/23 21:15:14
creating
| |
| 373 * with the values specified as arguments to this method, and taking | |
| 374 * the values of the this `DateTime` object for arguments that were omitted. | |
| 375 * | |
| 376 * # Example | |
| 377 * | |
| 378 * var dt = new DateTime(1969, 7, 20, 20, 18); | |
| 379 * var ut = dt.replace(day: 21, hour: 17, minute: 54); | |
| 380 * Expect.equals("1969-07-21T17:54:00.000", "$ut"); | |
| 381 * | |
| 382 */ | |
| 383 DateTime replace({int year, | |
|
floitsch
2015/11/23 19:11:01
I think we discussed this already on another class
sra1
2015/11/23 21:15:14
I would like to see `with` too.
We should have us
| |
| 384 int month, | |
| 385 int day, | |
| 386 int hour, | |
| 387 int minute, | |
| 388 int second, | |
| 389 int millisecond, | |
| 390 bool isUtc}) { | |
| 391 return new DateTime._internal(year ?? this.year, | |
| 392 month ?? this.month, | |
| 393 day ?? this.day, | |
| 394 hour ?? this.hour, | |
| 395 minute ?? this.minute, | |
| 396 second ?? this.second, | |
| 397 millisecond ?? this.millisecond, | |
| 398 isUtc ?? this.isUtc); | |
| 399 } | |
| 400 | |
| 401 /** | |
| 370 * Returns true if [other] is a [DateTime] at the same moment and in the | 402 * Returns true if [other] is a [DateTime] at the same moment and in the |
| 371 * same time zone (UTC or local). | 403 * same time zone (UTC or local). |
| 372 * | 404 * |
| 373 * DateTime dDayUtc = new DateTime.utc(1944, DateTime.JUNE, 6); | 405 * DateTime dDayUtc = new DateTime.utc(1944, DateTime.JUNE, 6); |
| 374 * DateTime dDayLocal = new DateTime(1944, DateTime.JUNE, 6); | 406 * DateTime dDayLocal = new DateTime(1944, DateTime.JUNE, 6); |
| 375 * | 407 * |
| 376 * assert(dDayUtc.isAtSameMomentAs(dDayLocal) == false); | 408 * assert(dDayUtc.isAtSameMomentAs(dDayLocal) == false); |
| 377 * | 409 * |
| 378 * See [isAtSameMomentAs] for a comparison that adjusts for time zone. | 410 * See [isAtSameMomentAs] for a comparison that adjusts for time zone. |
| 379 */ | 411 */ |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 * In accordance with ISO 8601 | 732 * In accordance with ISO 8601 |
| 701 * a week starts with Monday, which has the value 1. | 733 * a week starts with Monday, which has the value 1. |
| 702 * | 734 * |
| 703 * DateTime moonLanding = DateTime.parse("1969-07-20 20:18:00"); | 735 * DateTime moonLanding = DateTime.parse("1969-07-20 20:18:00"); |
| 704 * assert(moonLanding.weekday == 7); | 736 * assert(moonLanding.weekday == 7); |
| 705 * assert(moonLanding.weekday == DateTime.SUNDAY); | 737 * assert(moonLanding.weekday == DateTime.SUNDAY); |
| 706 * | 738 * |
| 707 */ | 739 */ |
| 708 external int get weekday; | 740 external int get weekday; |
| 709 } | 741 } |
| OLD | NEW |