diff --git a/core/common/src/Clock.kt b/core/common/src/Clock.kt index e9cd9137e..2fcc3d67d 100644 --- a/core/common/src/Clock.kt +++ b/core/common/src/Clock.kt @@ -78,7 +78,11 @@ public fun Clock.todayIn(timeZone: TimeZone): LocalDate = * Please only use this conversion function on the [Clock] instances that are fully controlled programmatically. */ @ExperimentalTime +@Deprecated("This function is deprecated because Clock.System.asTimeSource " + + "can be confused with TimeSource.Monotonic, which are very different. " + + "See https://github.com/Kotlin/kotlinx-datetime/issues/372", level = DeprecationLevel.WARNING) public fun Clock.asTimeSource(): TimeSource.WithComparableMarks = object : TimeSource.WithComparableMarks { + @ExperimentalTime override fun markNow(): ComparableTimeMark = InstantTimeMark(now(), this@asTimeSource) } diff --git a/core/common/test/ClockTimeSourceTest.kt b/core/common/test/ClockTimeSourceTest.kt index 561cd2221..17882ae6b 100644 --- a/core/common/test/ClockTimeSourceTest.kt +++ b/core/common/test/ClockTimeSourceTest.kt @@ -12,6 +12,7 @@ import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.nanoseconds @OptIn(ExperimentalTime::class) +@Suppress("DEPRECATION") class ClockTimeSourceTest { @Test fun arithmetic() {