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

Side by Side Diff: runtime/lib/date.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 | « lib/compiler/implementation/lib/mockimpl.dart ('k') | tests/corelib/date_time6_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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 const DateImplementation.fromEpoch(int this.value, 107 const DateImplementation.fromEpoch(int this.value,
108 TimeZone this.timeZone); 108 TimeZone this.timeZone);
109 109
110 bool operator ==(Object other) { 110 bool operator ==(Object other) {
111 if (!(other is DateImplementation)) return false; 111 if (!(other is DateImplementation)) return false;
112 return value == other.value && timeZone == other.timeZone; 112 return value == other.value && timeZone == other.timeZone;
113 } 113 }
114 114
115 bool operator <(Date other) => value < other.value;
116
117 bool operator <=(Date other) => value <= other.value;
118
119 bool operator >(Date other) => value > other.value;
120
121 bool operator >=(Date other) => value >= other.value;
122
115 int compareTo(Date other) => value.compareTo(other.value); 123 int compareTo(Date other) => value.compareTo(other.value);
116 int hashCode() => value; 124 int hashCode() => value;
117 125
118 Date changeTimeZone(TimeZone targetTimeZone) { 126 Date changeTimeZone(TimeZone targetTimeZone) {
119 if (targetTimeZone === null) { 127 if (targetTimeZone === null) {
120 targetTimeZone = new TimeZoneImplementation.local(); 128 targetTimeZone = new TimeZoneImplementation.local();
121 } 129 }
122 return new Date.fromEpoch(value, targetTimeZone); 130 return new Date.fromEpoch(value, targetTimeZone);
123 } 131 }
124 132
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 414
407 static int getHours_(int secondsSinceEpoch, bool isUtc) 415 static int getHours_(int secondsSinceEpoch, bool isUtc)
408 native "DateNatives_getHours"; 416 native "DateNatives_getHours";
409 417
410 static int getMinutes_(int secondsSinceEpoch, bool isUtc) 418 static int getMinutes_(int secondsSinceEpoch, bool isUtc)
411 native "DateNatives_getMinutes"; 419 native "DateNatives_getMinutes";
412 420
413 static int getSeconds_(int secondsSinceEpoch, bool isUtc) 421 static int getSeconds_(int secondsSinceEpoch, bool isUtc)
414 native "DateNatives_getSeconds"; 422 native "DateNatives_getSeconds";
415 } 423 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/mockimpl.dart ('k') | tests/corelib/date_time6_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698