Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: sdk/lib/core/duration.dart

Issue 2423993002: Emphasize that durations are context independent. (Closed)
Patch Set: More documentation. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« sdk/lib/core/date_time.dart ('K') | « sdk/lib/core/date_time.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 corresponding time intervall.
Lasse Reichstein Nielsen 2016/10/17 12:40:12 compute the corresponding -> compute the length of
floitsch 2016/10/17 12:50:25 Done.
22 *
14 * To create a new Duration object, use this class's single constructor 23 * To create a new Duration object, use this class's single constructor
15 * giving the appropriate arguments: 24 * giving the appropriate arguments:
16 * 25 *
17 * Duration fastestMarathon = new Duration(hours:2, minutes:3, seconds:2); 26 * Duration fastestMarathon = new Duration(hours:2, minutes:3, seconds:2);
18 * 27 *
19 * The Duration is the sum of all individual parts. 28 * The Duration is the sum of all individual parts.
20 * This means that individual parts can be larger than the next-bigger unit. 29 * This means that individual parts can be larger than the next-bigger unit.
21 * For example, [minutes] can be greater than 59. 30 * For example, [minutes] can be greater than 59.
22 * 31 *
23 * assert(fastestMarathon.inMinutes == 123); 32 * assert(fastestMarathon.inMinutes == 123);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 Duration abs() => new Duration._microseconds(_duration.abs()); 289 Duration abs() => new Duration._microseconds(_duration.abs());
281 290
282 /** 291 /**
283 * Returns a new `Duration` representing this `Duration` negated. 292 * Returns a new `Duration` representing this `Duration` negated.
284 * 293 *
285 * The returned `Duration` has the same length as this one, but will have the 294 * The returned `Duration` has the same length as this one, but will have the
286 * opposite sign of this one. 295 * opposite sign of this one.
287 */ 296 */
288 Duration operator -() => new Duration._microseconds(-_duration); 297 Duration operator -() => new Duration._microseconds(-_duration);
289 } 298 }
OLDNEW
« sdk/lib/core/date_time.dart ('K') | « sdk/lib/core/date_time.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698