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

Side by Side Diff: frog/lib/date_implementation.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 | « corelib/src/date.dart ('k') | lib/compiler/implementation/lib/mockimpl.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 4
5 // TODO(jmesserly): the native class should be the real JS Date. 5 // TODO(jmesserly): the native class should be the real JS Date.
6 // TODO(jimhug): Making the date value non-lazy might be a good path there. 6 // TODO(jimhug): Making the date value non-lazy might be a good path there.
7 class DateImplementation implements Date { 7 class DateImplementation implements Date {
8 final int value; 8 final int value;
9 final TimeZone timeZone; 9 final TimeZone timeZone;
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 bool operator ==(other) { 112 bool operator ==(other) {
113 if (!(other is DateImplementation)) return false; 113 if (!(other is DateImplementation)) return false;
114 return (value == other.value) && (timeZone == other.timeZone); 114 return (value == other.value) && (timeZone == other.timeZone);
115 } 115 }
116 116
117 int compareTo(Date other) { 117 int compareTo(Date other) {
118 return value.compareTo(other.value); 118 return value.compareTo(other.value);
119 } 119 }
120 120
121 int hashCode() {
122 return value;
123 }
124
121 Date changeTimeZone(TimeZone targetTimeZone) { 125 Date changeTimeZone(TimeZone targetTimeZone) {
122 if (targetTimeZone == null) { 126 if (targetTimeZone == null) {
123 targetTimeZone = new TimeZoneImplementation.local(); 127 targetTimeZone = new TimeZoneImplementation.local();
124 } 128 }
125 return new Date.fromEpoch(value, targetTimeZone); 129 return new Date.fromEpoch(value, targetTimeZone);
126 } 130 }
127 131
128 int get year() native 132 int get year() native
129 '''return this.isUtc() ? this._asJs().getUTCFullYear() : 133 '''return this.isUtc() ? this._asJs().getUTCFullYear() :
130 this._asJs().getFullYear();''' { 134 this._asJs().getFullYear();''' {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return isUtc == other.isUtc; 285 return isUtc == other.isUtc;
282 } 286 }
283 287
284 String toString() { 288 String toString() {
285 if (isUtc) return "TimeZone (UTC)"; 289 if (isUtc) return "TimeZone (UTC)";
286 return "TimeZone (Local)"; 290 return "TimeZone (Local)";
287 } 291 }
288 292
289 final bool isUtc; 293 final bool isUtc;
290 } 294 }
OLDNEW
« no previous file with comments | « corelib/src/date.dart ('k') | lib/compiler/implementation/lib/mockimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698