Skip to content

Commit 86a3523

Browse files
authored
Rename 'Clock.todayAt' to 'Clock.todayIn' (#206)
The other functions that accept a time zone use the word "in" in their names.
1 parent 4e39fbc commit 86a3523

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ by converting it to `LocalDateTime` and taking its `date` property.
137137
val now: Instant = Clock.System.now()
138138
val today: LocalDate = now.toLocalDateTime(TimeZone.currentSystemDefault()).date
139139
// or more short
140-
val today: LocalDate = Clock.System.todayAt(TimeZone.currentSystemDefault())
140+
val today: LocalDate = Clock.System.todayIn(TimeZone.currentSystemDefault())
141141
```
142142
Note, that today's date really depends on the time zone in which you're observing the current moment.
143143

core/common/src/Clock.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public interface Clock {
3333
/**
3434
* Returns the current date at the given [time zone][timeZone], according to [this Clock][this].
3535
*/
36-
public fun Clock.todayAt(timeZone: TimeZone): LocalDate =
37-
now().toLocalDateTime(timeZone).date
36+
public fun Clock.todayIn(timeZone: TimeZone): LocalDate =
37+
now().toLocalDateTime(timeZone).date
3838

3939
/**
4040
* Returns a [TimeSource] that uses this [Clock] to mark a time instant and to find the amount of time elapsed since that mark.
@@ -52,3 +52,6 @@ private class InstantTimeMark(private val instant: Instant, private val clock: C
5252

5353
override fun minus(duration: Duration): TimeMark = InstantTimeMark(instant - duration, clock)
5454
}
55+
56+
@Deprecated("Use Clock.todayIn instead", ReplaceWith("this.todayIn(timeZone)"), DeprecationLevel.WARNING)
57+
public fun Clock.todayAt(timeZone: TimeZone): LocalDate = todayIn(timeZone)

core/common/test/LocalDateTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class LocalDateTest {
106106
@Test
107107
@Suppress("UNUSED_VARIABLE")
108108
fun tomorrow() {
109-
val today = Clock.System.todayAt(TimeZone.currentSystemDefault())
109+
val today = Clock.System.todayIn(TimeZone.currentSystemDefault())
110110

111111
val nextMonthPlusDay1 = today.plus(DateTimeUnit.MONTH).plus(1, DateTimeUnit.DAY)
112112
val nextMonthPlusDay2 = today + DatePeriod(months = 1, days = 1)

0 commit comments

Comments
 (0)