From 4638de171453fada23d52efe162e71318cf6737b Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 31 Aug 2020 14:20:43 +0200 Subject: [PATCH] Fixed comparing Dates for equality on iOS --- .../net/dankito/utils/multiplatform/Date.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Date.kt b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Date.kt index e1b8d20e..25ba7b9a 100644 --- a/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Date.kt +++ b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Date.kt @@ -67,4 +67,23 @@ actual class Date(val date: NSDate) { // cannot subclass NSDate as it's a class return components.day.toInt() } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Date) return false + + if (date != other.date) return false + + return true + } + + override fun hashCode(): Int { + return date.hashCode() + } + + override fun toString(): String { + return date.description ?: "Date(date=$date)" + } + + } \ No newline at end of file