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 * A span of time, such as 27 days, 4 hours, 12 minutes, and 3 seconds. | 8 * A span of time, such as 27 days, 4 hours, 12 minutes, and 3 seconds. |
9 * | 9 * |
10 * A `Duration` represents a difference from one point in time to another. The | 10 * A `Duration` represents a difference from one point in time to another. The |
11 * duration may be "negative" if the difference is from a later time to an | 11 * duration may be "negative" if the difference is from a later time to an |
12 * earlier. | 12 * earlier. |
13 * | 13 * |
| 14 * Durations are context independent. For example, a duration of 2 days is |
| 15 * always 48 hours, even when it is added to a `DateTime` just when the |
| 16 * time zone is about to do a daylight-savings switch. (See [DateTime.add]). |
| 17 * |
| 18 * Despite the same name, a `Duration` object does not implement "Durations" |
| 19 * as specified by ISO 8601. In particular, a duration object does not keep |
| 20 * track of the individually provided members (such as "days" or "hours"), but |
| 21 * only uses these arguments to compute the length of the corresponding time |
| 22 * interval. |
| 23 * |
14 * To create a new Duration object, use this class's single constructor | 24 * To create a new Duration object, use this class's single constructor |
15 * giving the appropriate arguments: | 25 * giving the appropriate arguments: |
16 * | 26 * |
17 * Duration fastestMarathon = new Duration(hours:2, minutes:3, seconds:2); | 27 * Duration fastestMarathon = new Duration(hours:2, minutes:3, seconds:2); |
18 * | 28 * |
19 * The Duration is the sum of all individual parts. | 29 * The Duration is the sum of all individual parts. |
20 * This means that individual parts can be larger than the next-bigger unit. | 30 * This means that individual parts can be larger than the next-bigger unit. |
21 * For example, [minutes] can be greater than 59. | 31 * For example, [minutes] can be greater than 59. |
22 * | 32 * |
23 * assert(fastestMarathon.inMinutes == 123); | 33 * assert(fastestMarathon.inMinutes == 123); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 Duration abs() => new Duration._microseconds(_duration.abs()); | 290 Duration abs() => new Duration._microseconds(_duration.abs()); |
281 | 291 |
282 /** | 292 /** |
283 * Returns a new `Duration` representing this `Duration` negated. | 293 * Returns a new `Duration` representing this `Duration` negated. |
284 * | 294 * |
285 * The returned `Duration` has the same length as this one, but will have the | 295 * The returned `Duration` has the same length as this one, but will have the |
286 * opposite sign of this one. | 296 * opposite sign of this one. |
287 */ | 297 */ |
288 Duration operator -() => new Duration._microseconds(-_duration); | 298 Duration operator -() => new Duration._microseconds(-_duration); |
289 } | 299 } |
OLD | NEW |