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

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

Issue 11191078: Make hashCode a getter and not a method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 1 month 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 | Annotate | Revision Log
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 // Dart core library. 5 // Dart core library.
6 6
7 /** 7 /**
8 * A [Duration] represents a time span. A duration can be negative. 8 * A [Duration] represents a time span. A duration can be negative.
9 */ 9 */
10 class Duration implements Comparable { 10 class Duration implements Comparable {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 */ 78 */
79 int get inSeconds { 79 int get inSeconds {
80 return inMilliseconds ~/ Duration.MILLISECONDS_PER_SECOND; 80 return inMilliseconds ~/ Duration.MILLISECONDS_PER_SECOND;
81 } 81 }
82 82
83 bool operator ==(other) { 83 bool operator ==(other) {
84 if (other is !Duration) return false; 84 if (other is !Duration) return false;
85 return inMilliseconds == other.inMilliseconds; 85 return inMilliseconds == other.inMilliseconds;
86 } 86 }
87 87
88 int hashCode() { 88 int get hashCode {
89 return inMilliseconds.hashCode(); 89 return inMilliseconds.hashCode;
90 } 90 }
91 91
92 int compareTo(Duration other) { 92 int compareTo(Duration other) {
93 return inMilliseconds.compareTo(other.inMilliseconds); 93 return inMilliseconds.compareTo(other.inMilliseconds);
94 } 94 }
95 95
96 String toString() { 96 String toString() {
97 String threeDigits(int n) { 97 String threeDigits(int n) {
98 if (n >= 100) return "$n"; 98 if (n >= 100) return "$n";
99 if (n > 10) return "0$n"; 99 if (n > 10) return "0$n";
(...skipping 11 matching lines...) Expand all
111 } 111 }
112 String twoDigitMinutes = 112 String twoDigitMinutes =
113 twoDigits(inMinutes.remainder(Duration.MINUTES_PER_HOUR)); 113 twoDigits(inMinutes.remainder(Duration.MINUTES_PER_HOUR));
114 String twoDigitSeconds = 114 String twoDigitSeconds =
115 twoDigits(inSeconds.remainder(Duration.SECONDS_PER_MINUTE)); 115 twoDigits(inSeconds.remainder(Duration.SECONDS_PER_MINUTE));
116 String threeDigitMs = 116 String threeDigitMs =
117 threeDigits(inMilliseconds.remainder(Duration.MILLISECONDS_PER_SECOND)); 117 threeDigits(inMilliseconds.remainder(Duration.MILLISECONDS_PER_SECOND));
118 return "$inHours:$twoDigitMinutes:$twoDigitSeconds.$threeDigitMs"; 118 return "$inHours:$twoDigitMinutes:$twoDigitSeconds.$threeDigitMs";
119 } 119 }
120 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698