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

Side by Side Diff: frog/lib/date_implementation.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 | « 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 } 98 }
99 99
100 const DateImplementation.fromEpoch(this.value, this.timeZone); 100 const DateImplementation.fromEpoch(this.value, this.timeZone);
101 101
102 bool operator ==(other) { 102 bool operator ==(other) {
103 if (!(other is DateImplementation)) return false; 103 if (!(other is DateImplementation)) return false;
104 return (value == other.value) && (timeZone == other.timeZone); 104 return (value == other.value) && (timeZone == other.timeZone);
105 } 105 }
106 106
107 bool operator <(Date other) => value < other.value;
108
109 bool operator <=(Date other) => value <= other.value;
110
111 bool operator >(Date other) => value > other.value;
112
113 bool operator >=(Date other) => value >= other.value;
114
107 int compareTo(Date other) { 115 int compareTo(Date other) {
108 return value.compareTo(other.value); 116 return value.compareTo(other.value);
109 } 117 }
110 118
111 int hashCode() { 119 int hashCode() {
112 return value; 120 return value;
113 } 121 }
114 122
115 Date changeTimeZone(TimeZone targetTimeZone) { 123 Date changeTimeZone(TimeZone targetTimeZone) {
116 if (targetTimeZone == null) { 124 if (targetTimeZone == null) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return isUtc == other.isUtc; 283 return isUtc == other.isUtc;
276 } 284 }
277 285
278 String toString() { 286 String toString() {
279 if (isUtc) return "TimeZone (UTC)"; 287 if (isUtc) return "TimeZone (UTC)";
280 return "TimeZone (Local)"; 288 return "TimeZone (Local)";
281 } 289 }
282 290
283 final bool isUtc; 291 final bool isUtc;
284 } 292 }
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