Index: sdk/lib/core/date_time.dart |
diff --git a/sdk/lib/core/date_time.dart b/sdk/lib/core/date_time.dart |
index cbeeccd6abacf97baf4a416e275bcbf564ebfd48..d1a613dc28847149c120b2d8d1e4c01cbe5949b5 100644 |
--- a/sdk/lib/core/date_time.dart |
+++ b/sdk/lib/core/date_time.dart |
@@ -272,19 +272,24 @@ class DateTime implements Date { |
} |
/** |
- * Returns true if [this] occurs at the same time as [other]. The |
- * comparison is independent of whether the time is utc or in the local |
- * time zone. |
+ * Returns true if [other] is a [DateTime] at the same moment and in the |
+ * same timezone (UTC or local). |
+ * |
+ * See [isAtSameMomentAs] for a comparison that ignores the timezone. |
*/ |
bool operator ==(other) { |
if (!(other is DateTime)) return false; |
- return (millisecondsSinceEpoch == other.millisecondsSinceEpoch); |
+ return (millisecondsSinceEpoch == other.millisecondsSinceEpoch && |
+ isUtc == other.isUtc); |
} |
/** |
* Returns true if [this] occurs before [other]. The comparison is independent |
* of whether the time is utc or in the local time zone. |
+ * |
+ * *Deprecated* Use [isBefore] instead. |
*/ |
+ @deprecated |
bool operator <(DateTime other) |
=> millisecondsSinceEpoch < other.millisecondsSinceEpoch; |
@@ -292,14 +297,20 @@ class DateTime implements Date { |
* Returns true if [this] occurs at the same time or before [other]. The |
* comparison is independent of whether the time is utc or in the local |
* time zone. |
+ * |
+ * *Deprecated* Use [isAfter] instead (`!isAfter`). |
Lasse Reichstein Nielsen
2013/02/11 13:05:20
Don't use backquote.
Consider adding isNotAfter.
floitsch
2013/02/11 21:12:16
I prefer not to.
But we can discuss this. For now
|
*/ |
+ @deprecated |
bool operator <=(DateTime other) |
=> millisecondsSinceEpoch <= other.millisecondsSinceEpoch; |
/** |
* Returns true if [this] occurs after [other]. The comparison is independent |
* of whether the time is utc or in the local time zone. |
+ * |
+ * *Deprecated* Use [isAfter] instead. |
*/ |
+ @deprecated |
bool operator >(DateTime other) |
=> millisecondsSinceEpoch > other.millisecondsSinceEpoch; |
@@ -307,10 +318,38 @@ class DateTime implements Date { |
* Returns true if [this] occurs at the same time or after [other]. The |
* comparison is independent of whether the time is utc or in the local |
* time zone. |
+ * |
+ * *Deprecated* Use [isBefore] instead (`!isBefore`). |
*/ |
+ @deprecated |
bool operator >=(DateTime other) |
=> millisecondsSinceEpoch >= other.millisecondsSinceEpoch; |
+ /** |
+ * Returns true if [this] occurs before [other]. The comparison is independent |
+ * of whether the time is utc or in the local time zone. |
+ */ |
+ bool isBefore(DateTime other) { |
+ return millisecondsSinceEpoch < other.millisecondsSinceEpoch; |
+ } |
+ |
+ /** |
+ * Returns true if [this] occurs after [other]. The comparison is independent |
+ * of whether the time is utc or in the local time zone. |
+ */ |
+ bool isAfter(DateTime other) { |
+ return millisecondsSinceEpoch > other.millisecondsSinceEpoch; |
+ } |
+ |
+ /** |
+ * Returns true if [this] occurs at the same moment as [other]. The |
+ * comparison is independent of whether the time is utc or in the local |
Lasse Reichstein Nielsen
2013/02/11 13:05:20
'is UTC' => 'is in UTC'
floitsch
2013/02/11 21:12:16
Done.
|
+ * time zone. |
+ */ |
+ bool isAtSameMomentAs(DateTime other) { |
+ return millisecondsSinceEpoch == other.millisecondsSinceEpoch; |
+ } |
+ |
int compareTo(DateTime other) |
=> millisecondsSinceEpoch.compareTo(other.millisecondsSinceEpoch); |