| 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 // 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |