Skip to content

Commit f829958

Browse files
committed
Restore Instant and Clock as type aliases to kotlin.time
1 parent b20c354 commit f829958

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

core/common/src/DeprecatedClock.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019-2025 JetBrains s.r.o. and contributors.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
package kotlinx.datetime
7+
8+
/**
9+
* This is a deprecated type alias for `kotlinx.datetime.Clock`.
10+
*
11+
* Before 0.7.0, this type was used to represent a clock in the `kotlinx.datetime` library.
12+
* However, in Kotlin 2.1.20,
13+
* the `kotlin.time.Clock` type was introduced and is now the preferred way to represent a clock.
14+
*
15+
* This type alias is kept for making sure the existing code that uses `kotlinx.datetime.Clock` compiles.
16+
* For ensuring binary compatibility instead of source compatibility,
17+
* see <https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#deprecation-of-instant>.
18+
*/
19+
@Deprecated(
20+
"This type is deprecated in favor of `kotlin.time.Clock`.",
21+
level = DeprecationLevel.WARNING,
22+
replaceWith = ReplaceWith("kotlin.time.Clock", "kotlin.time.Clock"))
23+
public typealias Clock = kotlin.time.Clock

core/common/src/DeprecatedInstant.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2019-2025 JetBrains s.r.o. and contributors.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
package kotlinx.datetime
7+
8+
/**
9+
* This is a deprecated type alias for `kotlinx.datetime.Instant`.
10+
*
11+
* Before 0.7.0, this type was used to represent a clock in the `kotlinx.datetime` library.
12+
* However, in Kotlin 2.1.20,
13+
* the `kotlin.time.Instant` type was introduced and is now the preferred way to represent a moment in time.
14+
*
15+
* This type alias is kept for making sure the existing code that uses `kotlinx.datetime.Instant` compiles.
16+
* For ensuring binary compatibility instead of source compatibility,
17+
* see <https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#deprecation-of-instant>.
18+
*/
19+
@Deprecated(
20+
"This type is deprecated in favor of `kotlin.time.Instant`.",
21+
level = DeprecationLevel.WARNING,
22+
replaceWith = ReplaceWith("kotlin.time.Instant", "kotlin.time.Instant"))
23+
public typealias Instant = kotlin.time.Instant

0 commit comments

Comments
 (0)