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

Side by Side Diff: runtime/lib/date.dart

Issue 10391109: Add Hashable to Date interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/lib/mockimpl.dart ('k') | tests/corelib/date_time2_test.dart » ('j') | 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 // Dart core library. 4 // Dart core library.
5 5
6 class TimeZoneImplementation implements TimeZone { 6 class TimeZoneImplementation implements TimeZone {
7 const TimeZoneImplementation.utc() : isUtc = true; 7 const TimeZoneImplementation.utc() : isUtc = true;
8 TimeZoneImplementation.local() : isUtc = false {} 8 TimeZoneImplementation.local() : isUtc = false {}
9 9
10 bool operator ==(Object other) { 10 bool operator ==(Object other) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 const DateImplementation.fromEpoch(int this.value, 117 const DateImplementation.fromEpoch(int this.value,
118 TimeZone this.timeZone); 118 TimeZone this.timeZone);
119 119
120 bool operator ==(Object other) { 120 bool operator ==(Object other) {
121 if (!(other is DateImplementation)) return false; 121 if (!(other is DateImplementation)) return false;
122 return value == other.value && timeZone == other.timeZone; 122 return value == other.value && timeZone == other.timeZone;
123 } 123 }
124 124
125 int compareTo(Date other) { 125 int compareTo(Date other) => value.compareTo(other.value);
126 return value.compareTo(other.value); 126 int hashCode() => value;
127 }
128 127
129 Date changeTimeZone(TimeZone targetTimeZone) { 128 Date changeTimeZone(TimeZone targetTimeZone) {
130 if (targetTimeZone === null) { 129 if (targetTimeZone === null) {
131 targetTimeZone = new TimeZoneImplementation.local(); 130 targetTimeZone = new TimeZoneImplementation.local();
132 } 131 }
133 return new Date.fromEpoch(value, targetTimeZone); 132 return new Date.fromEpoch(value, targetTimeZone);
134 } 133 }
135 134
136 int get year() { 135 int get year() {
137 int secondsSinceEpoch = secondsSinceEpoch_; 136 int secondsSinceEpoch = secondsSinceEpoch_;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 416
418 static int getHours_(int secondsSinceEpoch, bool isUtc) 417 static int getHours_(int secondsSinceEpoch, bool isUtc)
419 native "DateNatives_getHours"; 418 native "DateNatives_getHours";
420 419
421 static int getMinutes_(int secondsSinceEpoch, bool isUtc) 420 static int getMinutes_(int secondsSinceEpoch, bool isUtc)
422 native "DateNatives_getMinutes"; 421 native "DateNatives_getMinutes";
423 422
424 static int getSeconds_(int secondsSinceEpoch, bool isUtc) 423 static int getSeconds_(int secondsSinceEpoch, bool isUtc)
425 native "DateNatives_getSeconds"; 424 native "DateNatives_getSeconds";
426 } 425 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/mockimpl.dart ('k') | tests/corelib/date_time2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698