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

Side by Side Diff: lib/compiler/implementation/lib/mockimpl.dart

Issue 10399027: Add comparison operators to Date class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add new lines. 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 | « frog/lib/date_implementation.dart ('k') | runtime/lib/date.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Mocks of classes and interfaces that Leg cannot read directly. 5 // Mocks of classes and interfaces that Leg cannot read directly.
6 6
7 // TODO(ahe): Remove this file. 7 // TODO(ahe): Remove this file.
8 8
9 class JSSyntaxRegExp implements RegExp { 9 class JSSyntaxRegExp implements RegExp {
10 final String pattern; 10 final String pattern;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 } 272 }
273 273
274 const DateImplementation.fromEpoch(this.value, this.timeZone); 274 const DateImplementation.fromEpoch(this.value, this.timeZone);
275 275
276 bool operator ==(other) { 276 bool operator ==(other) {
277 if (!(other is DateImplementation)) return false; 277 if (!(other is DateImplementation)) return false;
278 return (value == other.value) && (timeZone == other.timeZone); 278 return (value == other.value) && (timeZone == other.timeZone);
279 } 279 }
280 280
281 int compareTo(Date other) { 281 bool operator <(Date other) => value < other.value;
282 checkNull(other); 282
283 return value.compareTo(other.value); 283 bool operator <=(Date other) => value <= other.value;
284 } 284
285 bool operator >(Date other) => value > other.value;
286
287 bool operator >=(Date other) => value >= other.value;
288
289 int compareTo(Date other) => value.compareTo(other.value);
285 290
286 int hashCode() => value; 291 int hashCode() => value;
287 292
288 Date changeTimeZone(TimeZone targetTimeZone) { 293 Date changeTimeZone(TimeZone targetTimeZone) {
289 if (targetTimeZone == null) { 294 if (targetTimeZone == null) {
290 targetTimeZone = new TimeZoneImplementation.local(); 295 targetTimeZone = new TimeZoneImplementation.local();
291 } 296 }
292 return new Date.fromEpoch(value, targetTimeZone); 297 return new Date.fromEpoch(value, targetTimeZone);
293 } 298 }
294 299
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 factory List.from(Iterable<E> other) { 390 factory List.from(Iterable<E> other) {
386 List<E> result = new List<E>(); 391 List<E> result = new List<E>();
387 // TODO(ahe): Use for-in when it is implemented correctly. 392 // TODO(ahe): Use for-in when it is implemented correctly.
388 Iterator<E> iterator = other.iterator(); 393 Iterator<E> iterator = other.iterator();
389 while (iterator.hasNext()) { 394 while (iterator.hasNext()) {
390 result.add(iterator.next()); 395 result.add(iterator.next());
391 } 396 }
392 return result; 397 return result;
393 } 398 }
394 } 399 }
OLDNEW
« no previous file with comments | « frog/lib/date_implementation.dart ('k') | runtime/lib/date.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698