diff --git a/gradle.properties b/gradle.properties index cbe434d..0882646 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ # sytleguide kotlin.code.style=official -# Kotlin 1.4.30-RC: https://github.com/korlibs/easy-kotlin-mpp-gradle-plugin -easyPluginVersion=0.12.5 +# Kotlin 1.4.30: https://github.com/korlibs/easy-kotlin-mpp-gradle-plugin +easyPluginVersion=0.13.0 # version group=com.soywiz.korlibs.klock diff --git a/klock/src/commonMain/kotlin/com/soywiz/klock/DateTime.kt b/klock/src/commonMain/kotlin/com/soywiz/klock/DateTime.kt index f7f7d5c..888b39c 100644 --- a/klock/src/commonMain/kotlin/com/soywiz/klock/DateTime.kt +++ b/klock/src/commonMain/kotlin/com/soywiz/klock/DateTime.kt @@ -422,8 +422,8 @@ inline class DateTime( override fun toString(): String = DateFormat.DEFAULT_FORMAT.format(this) } -fun max(a: DateTime, b: DateTime): DateTime = DateTime.fromUnix(max(a.unixMillis, b.unixMillis)) -fun min(a: DateTime, b: DateTime): DateTime = DateTime.fromUnix(min(a.unixMillis, b.unixMillis)) +fun max(a: DateTime, b: DateTime): DateTime = DateTime.fromUnix(max2(a.unixMillis, b.unixMillis)) +fun min(a: DateTime, b: DateTime): DateTime = DateTime.fromUnix(min2(a.unixMillis, b.unixMillis)) fun DateTime.clamp(min: DateTime, max: DateTime): DateTime = when { this < min -> min this > max -> max diff --git a/klock/src/commonMain/kotlin/com/soywiz/klock/TimeSpan.kt b/klock/src/commonMain/kotlin/com/soywiz/klock/TimeSpan.kt index fdab2df..ed7914a 100644 --- a/klock/src/commonMain/kotlin/com/soywiz/klock/TimeSpan.kt +++ b/klock/src/commonMain/kotlin/com/soywiz/klock/TimeSpan.kt @@ -208,8 +208,8 @@ inline class TimeSpan( fun TimeSpan.toTimeString(components: Int = 3, addMilliseconds: Boolean = false): String = TimeSpan.toTimeString(milliseconds, components, addMilliseconds) -fun max(a: TimeSpan, b: TimeSpan): TimeSpan = max(a.milliseconds, b.milliseconds).milliseconds -fun min(a: TimeSpan, b: TimeSpan): TimeSpan = min(a.milliseconds, b.milliseconds).milliseconds +fun max(a: TimeSpan, b: TimeSpan): TimeSpan = max2(a.milliseconds, b.milliseconds).milliseconds +fun min(a: TimeSpan, b: TimeSpan): TimeSpan = min2(a.milliseconds, b.milliseconds).milliseconds fun TimeSpan.clamp(min: TimeSpan, max: TimeSpan): TimeSpan = when { this < min -> min this > max -> max diff --git a/klock/src/commonMain/kotlin/com/soywiz/klock/internal/internal.kt b/klock/src/commonMain/kotlin/com/soywiz/klock/internal/internal.kt index 4528950..8e6d9af 100644 --- a/klock/src/commonMain/kotlin/com/soywiz/klock/internal/internal.kt +++ b/klock/src/commonMain/kotlin/com/soywiz/klock/internal/internal.kt @@ -89,3 +89,12 @@ internal class Moduler(val value: Double) { } internal infix fun Double.intDiv(other: Double) = floor(this / other) + +@PublishedApi internal fun min2(a: Int, b: Int) = if (a < b) a else b +@PublishedApi internal fun max2(a: Int, b: Int) = if (a > b) a else b + +@PublishedApi internal fun min2(a: Float, b: Float) = if (a < b) a else b +@PublishedApi internal fun max2(a: Float, b: Float) = if (a > b) a else b + +@PublishedApi internal fun min2(a: Double, b: Double) = if (a < b) a else b +@PublishedApi internal fun max2(a: Double, b: Double) = if (a > b) a else b diff --git a/klock/src/commonTest/kotlin/com/soywiz/klock/DateTimeRangeSetTest.kt b/klock/src/commonTest/kotlin/com/soywiz/klock/DateTimeRangeSetTest.kt index 16a8e15..2021930 100644 --- a/klock/src/commonTest/kotlin/com/soywiz/klock/DateTimeRangeSetTest.kt +++ b/klock/src/commonTest/kotlin/com/soywiz/klock/DateTimeRangeSetTest.kt @@ -1,5 +1,6 @@ package com.soywiz.klock +import com.soywiz.klock.internal.* import kotlin.math.max import kotlin.math.min import kotlin.random.Random @@ -33,7 +34,7 @@ class DateTimeRangeSetTest { fun randomRange(): DateTimeRange { val a = random.nextInt(min, max) val b = random.nextInt(min, max) - return range(min(a, b), max(a, b)) + return range(min2(a, b), max2(a, b)) } return (0 until count).map { randomRange() } }