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 | 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 | 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]). | 16 * time zone is about to do a daylight-savings switch. (See [DateTime.add]). |
17 * | 17 * |
18 * Despite the same name, a `Duration` object does not implement "Durations" | 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 | 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 | 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 | 21 * only uses these arguments to compute the length of the corresponding time |
22 * interval. | 22 * interval. |
23 * | 23 * |
24 * 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 |
25 * giving the appropriate arguments: | 25 * giving the appropriate arguments: |
26 * | 26 * |
27 * Duration fastestMarathon = new Duration(hours:2, minutes:3, seconds:2); | 27 * Duration fastestMarathon = new Duration(hours:2, minutes:3, seconds:2); |
28 * | 28 * |
29 * The Duration is the sum of all individual parts. | 29 * The [Duration] is the sum of all individual parts. |
30 * 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. |
31 * For example, [minutes] can be greater than 59. | 31 * For example, [inMinutes] can be greater than 59. |
32 * | 32 * |
33 * assert(fastestMarathon.inMinutes == 123); | 33 * assert(fastestMarathon.inMinutes == 123); |
34 * | 34 * |
35 * All individual parts are allowed to be negative. | 35 * All individual parts are allowed to be negative. |
36 * | 36 * |
37 * Use one of the properties, such as [inDays], | 37 * Use one of the properties, such as [inDays], |
38 * to retrieve the integer value of the Duration in the specified time unit. | 38 * to retrieve the integer value of the Duration in the specified time unit. |
39 * Note that the returned value is rounded down. | 39 * Note that the returned value is rounded down. |
40 * For example, | 40 * For example, |
41 * | 41 * |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 289 |
290 /** | 290 /** |
291 * Returns a new `Duration` representing this `Duration` negated. | 291 * Returns a new `Duration` representing this `Duration` negated. |
292 * | 292 * |
293 * The returned `Duration` has the same length as this one, but will have the | 293 * The returned `Duration` has the same length as this one, but will have the |
294 * opposite sign of this one. | 294 * opposite sign of this one. |
295 */ | 295 */ |
296 // Using subtraction helps dart2js avoid negative zeros. | 296 // Using subtraction helps dart2js avoid negative zeros. |
297 Duration operator -() => new Duration._microseconds(0 - _duration); | 297 Duration operator -() => new Duration._microseconds(0 - _duration); |
298 } | 298 } |
OLD | NEW |