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 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 * All individual parts are allowed to be negative. | 86 * All individual parts are allowed to be negative. |
87 * All arguments are 0 by default. | 87 * All arguments are 0 by default. |
88 */ | 88 */ |
89 const Duration({int days: 0, | 89 const Duration({int days: 0, |
90 int hours: 0, | 90 int hours: 0, |
91 int minutes: 0, | 91 int minutes: 0, |
92 int seconds: 0, | 92 int seconds: 0, |
93 int milliseconds: 0, | 93 int milliseconds: 0, |
94 int microseconds: 0}) | 94 int microseconds: 0}) |
95 : this._microseconds( | 95 : this._microseconds( |
96 days * MICROSECONDS_PER_DAY + | 96 MICROSECONDS_PER_DAY * days + |
97 hours * MICROSECONDS_PER_HOUR + | 97 MICROSECONDS_PER_HOUR * hours + |
98 minutes * MICROSECONDS_PER_MINUTE + | 98 MICROSECONDS_PER_MINUTE * minutes + |
99 seconds * MICROSECONDS_PER_SECOND + | 99 MICROSECONDS_PER_SECOND * seconds + |
100 milliseconds * MICROSECONDS_PER_MILLISECOND + | 100 MICROSECONDS_PER_MILLISECOND * milliseconds + |
101 microseconds); | 101 microseconds); |
102 | 102 |
103 // Fast path internal direct constructor to avoids the optional arguments and | 103 // Fast path internal direct constructor to avoids the optional arguments and |
104 // [_microseconds] recomputation. | 104 // [_microseconds] recomputation. |
105 const Duration._microseconds(this._duration); | 105 const Duration._microseconds(this._duration); |
106 | 106 |
107 /** | 107 /** |
108 * Adds this Duration and [other] and | 108 * Adds this Duration and [other] and |
109 * returns the sum as a new Duration object. | 109 * returns the sum as a new Duration object. |
110 */ | 110 */ |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 Duration abs() => new Duration._microseconds(_duration.abs()); | 280 Duration abs() => new Duration._microseconds(_duration.abs()); |
281 | 281 |
282 /** | 282 /** |
283 * Returns a new `Duration` representing this `Duration` negated. | 283 * Returns a new `Duration` representing this `Duration` negated. |
284 * | 284 * |
285 * The returned `Duration` has the same length as this one, but will have the | 285 * The returned `Duration` has the same length as this one, but will have the |
286 * opposite sign of this one. | 286 * opposite sign of this one. |
287 */ | 287 */ |
288 Duration operator -() => new Duration._microseconds(-_duration); | 288 Duration operator -() => new Duration._microseconds(-_duration); |
289 } | 289 } |
OLD | NEW |