| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 return "$y-$m-${d}T$h:$min:$sec.$ms${us}Z"; | 565 return "$y-$m-${d}T$h:$min:$sec.$ms${us}Z"; |
| 566 } else { | 566 } else { |
| 567 return "$y-$m-${d}T$h:$min:$sec.$ms$us"; | 567 return "$y-$m-${d}T$h:$min:$sec.$ms$us"; |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 | 570 |
| 571 /** | 571 /** |
| 572 * Returns a new [DateTime] instance with [duration] added to [this]. | 572 * Returns a new [DateTime] instance with [duration] added to [this]. |
| 573 * | 573 * |
| 574 * DateTime today = new DateTime.now(); | 574 * DateTime today = new DateTime.now(); |
| 575 * DateTime sixtyDaysFromNow = today.add(new Duration(days: 60)); | 575 * DateTime fiftyDaysFromNow = today.add(new Duration(days: 50)); |
| 576 * |
| 577 * Notice that the duration being added is actually 50 * 24 * 60 * 60 |
| 578 * seconds. If the resulting `DateTime` has a different daylight saving offset |
| 579 * than `this`, then the result won't have the same time-of-day as `this`, and |
| 580 * may not even hit the calendar date 50 days later. |
| 581 * |
| 582 * Be careful when working with dates in local time. |
| 576 */ | 583 */ |
| 577 external DateTime add(Duration duration); | 584 external DateTime add(Duration duration); |
| 578 | 585 |
| 579 /** | 586 /** |
| 580 * Returns a new [DateTime] instance with [duration] subtracted from [this]. | 587 * Returns a new [DateTime] instance with [duration] subtracted from [this]. |
| 581 * | 588 * |
| 582 * DateTime today = new DateTime.now(); | 589 * DateTime today = new DateTime.now(); |
| 583 * DateTime sixtyDaysAgo = today.subtract(new Duration(days: 30)); | 590 * DateTime fiftyDaysAgo = today.subtract(new Duration(days: 50)); |
| 584 * | 591 * |
| 585 * Notice that duration being subtracted is actually 30 * 24 * 60 * 60 seconds | 592 * Notice that the duration being subtracted is actually 50 * 24 * 60 * 60 |
| 586 * and if that crosses a daylight saving time change, the resulting `DateTime` | 593 * seconds. If the resulting `DateTime` has a different daylight saving offset |
| 587 * won't have the same time of day as `today`, and may not actually hit the | 594 * than `this`, then the result won't have the same time-of-day as `this`, and |
| 588 * calendar date 30 days earlier. Be careful when working with dates in local | 595 * may not even hit the calendar date 50 days earlier. |
| 589 * time. | 596 * |
| 597 * Be careful when working with dates in local time. |
| 590 */ | 598 */ |
| 591 external DateTime subtract(Duration duration); | 599 external DateTime subtract(Duration duration); |
| 592 | 600 |
| 593 /** | 601 /** |
| 594 * Returns a [Duration] with the difference between [this] and [other]. | 602 * Returns a [Duration] with the difference between [this] and [other]. |
| 595 * | 603 * |
| 596 * DateTime berlinWallFell = new DateTime.utc(1989, DateTime.NOVEMBER, 9); | 604 * DateTime berlinWallFell = new DateTime.utc(1989, DateTime.NOVEMBER, 9); |
| 597 * DateTime dDay = new DateTime.utc(1944, DateTime.JUNE, 6); | 605 * DateTime dDay = new DateTime.utc(1944, DateTime.JUNE, 6); |
| 598 * | 606 * |
| 599 * Duration difference = berlinWallFell.difference(dDay); | 607 * Duration difference = berlinWallFell.difference(dDay); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 * In accordance with ISO 8601 | 766 * In accordance with ISO 8601 |
| 759 * a week starts with Monday, which has the value 1. | 767 * a week starts with Monday, which has the value 1. |
| 760 * | 768 * |
| 761 * DateTime moonLanding = DateTime.parse("1969-07-20 20:18:00"); | 769 * DateTime moonLanding = DateTime.parse("1969-07-20 20:18:00"); |
| 762 * assert(moonLanding.weekday == 7); | 770 * assert(moonLanding.weekday == 7); |
| 763 * assert(moonLanding.weekday == DateTime.SUNDAY); | 771 * assert(moonLanding.weekday == DateTime.SUNDAY); |
| 764 * | 772 * |
| 765 */ | 773 */ |
| 766 external int get weekday; | 774 external int get weekday; |
| 767 } | 775 } |
| OLD | NEW |