Skip to content

Commit f7878af

Browse files
danil-pavlovdkhalanskyjb
authored andcommitted
feat: new docs review
1 parent a2af2de commit f7878af

File tree

10 files changed

+98
-98
lines changed

10 files changed

+98
-98
lines changed

core/common/src/Clock.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import kotlin.time.*
1212
*
1313
* See [Clock.System][Clock.System] for the clock instance that queries the operating system.
1414
*
15-
* It is recommended not to use [Clock.System] directly in the implementation; instead, one could pass a
16-
* [Clock] explicitly to the functions or classes that need it.
15+
* It is not recommended to use [Clock.System] directly in the implementation. Instead, you can pass a
16+
* [Clock] explicitly to the necessary functions or classes.
1717
* This way, tests can be written deterministically by providing custom [Clock] implementations
1818
* to the system under test.
1919
*/
@@ -24,7 +24,7 @@ public interface Clock {
2424
* It is not guaranteed that calling [now] later will return a larger [Instant].
2525
* In particular, for [Clock.System] it is completely expected that the opposite will happen,
2626
* and it must be taken into account.
27-
* See the documentation of [Clock.System] for details.
27+
* See the [System] documentation for details.
2828
*
2929
* Even though [Instant] is defined to be on the UTC-SLS time scale, which enforces a specific way of handling
3030
* leap seconds, [now] is not guaranteed to handle leap seconds in any specific way.
@@ -38,15 +38,14 @@ public interface Clock {
3838
* these increases will not necessarily correspond to the elapsed time.
3939
*
4040
* For example, when using [Clock.System], the following could happen:
41-
* - [now] returns `2023-01-02T22:35:01Z`;
42-
* - The system queries the Internet and recognizes that its clock needs adjusting;
41+
* - [now] returns `2023-01-02T22:35:01Z`.
42+
* - The system queries the Internet and recognizes that its clock needs adjusting.
4343
* - [now] returns `2023-01-02T22:32:05Z`.
4444
*
45-
* When predictable intervals between successive measurements are needed, consider using
46-
* [TimeSource.Monotonic].
45+
* When you need predictable intervals between successive measurements, consider using [TimeSource.Monotonic].
4746
*
48-
* For improved testability, one could avoid using [Clock.System] directly in the implementation,
49-
* instead passing a [Clock] explicitly. For example:
47+
* For improved testability, you should avoid using [Clock.System] directly in the implementation
48+
* and pass a [Clock] explicitly instead. For example:
5049
*
5150
* @sample kotlinx.datetime.test.samples.ClockSamples.system
5251
* @sample kotlinx.datetime.test.samples.ClockSamples.dependencyInjection
@@ -74,7 +73,7 @@ public fun Clock.todayIn(timeZone: TimeZone): LocalDate =
7473
/**
7574
* Returns a [TimeSource] that uses this [Clock] to mark a time instant and to find the amount of time elapsed since that mark.
7675
*
77-
* **Pitfall**: using this function with [Clock.System] is error-prone,
76+
* **Pitfall**: using this function with [Clock.System] is error-prone
7877
* because [Clock.System] is not well suited for measuring time intervals.
7978
* Please only use this conversion function on the [Clock] instances that are fully controlled programmatically.
8079
*/

core/common/src/DateTimePeriod.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import kotlinx.serialization.Serializable
1717
/**
1818
* A difference between two [instants][Instant], decomposed into date and time components.
1919
*
20-
* The date components are: [years] ([DateTimeUnit.YEAR]), [months] ([DateTimeUnit.MONTH]), [days] ([DateTimeUnit.DAY]).
20+
* The date components are: [years] ([DateTimeUnit.YEAR]), [months] ([DateTimeUnit.MONTH]), and [days] ([DateTimeUnit.DAY]).
2121
*
2222
* The time components are: [hours] ([DateTimeUnit.HOUR]), [minutes] ([DateTimeUnit.MINUTE]),
23-
* [seconds] ([DateTimeUnit.SECOND]), [nanoseconds] ([DateTimeUnit.NANOSECOND]).
23+
* [seconds] ([DateTimeUnit.SECOND]), and [nanoseconds] ([DateTimeUnit.NANOSECOND]).
2424
*
2525
* The time components are not independent and are always normalized together.
2626
* Likewise, months are normalized together with years.
@@ -428,7 +428,7 @@ public class DatePeriod internal constructor(
428428
/**
429429
* Constructs a new [DatePeriod].
430430
*
431-
* It is recommended to always explicitly name the arguments when constructing this manually,
431+
* It is always recommended to name the arguments explicitly when constructing this manually,
432432
* like `DatePeriod(years = 1, months = 12, days = 16)`.
433433
*
434434
* The passed numbers are not stored as is but are normalized instead for human readability, so, for example,

core/common/src/DateTimeUnit.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ import kotlin.time.Duration.Companion.nanoseconds
2020
*
2121
* ### Interaction with other entities
2222
*
23-
* Any [DateTimeUnit] can be used with [Instant.plus], [Instant.minus] to
23+
* Any [DateTimeUnit] can be used with [Instant.plus] or [Instant.minus] to
2424
* find an instant that is some number of units away from the given instant.
2525
* Also, [Instant.until] can be used to find the number of the given units between two instants.
2626
*
27-
* [DateTimeUnit.TimeBased] can be used in the [Instant] operations without specifying the time zone, because
28-
* [DateTimeUnit.TimeBased] is defined in terms of passage of real time, and is independent of the time zone.
27+
* [DateTimeUnit.TimeBased] can be used in the [Instant] operations without specifying the time zone because
28+
* [DateTimeUnit.TimeBased] is defined in terms of the passage of real-time and is independent of the time zone.
2929
* Note that a calendar day is not considered identical to 24 hours, so using it does require specifying the time zone.
3030
* See [DateTimeUnit.DayBased] for an explanation.
3131
*
3232
* [DateTimeUnit.DateBased] units can be used in the [LocalDate] operations: [LocalDate.plus], [LocalDate.minus], and
3333
* [LocalDate.until].
3434
*
3535
* Arithmetic operations on [LocalDateTime] are not provided.
36-
* Please see the [LocalDateTime] documentation for a discussion.
36+
* Please see the [LocalDateTime] documentation for details.
3737
*
38-
* [DateTimePeriod] is a combination of [DateTimeUnit] values of every kind, used to express things like
39-
* "two days and three hours."
38+
* [DateTimePeriod] is a combination of [DateTimeUnit] values of every kind, used to express periods like
39+
* "two days and three hours".
4040
* [DatePeriod] is specifically a combination of [DateTimeUnit.DateBased] values.
4141
* [DateTimePeriod] is more flexible than [DateTimeUnit] because it can express a combination of values with different
4242
* kinds of units, but in exchange, the duration of time between two [Instant] or [LocalDate] values can be
@@ -48,8 +48,8 @@ import kotlin.time.Duration.Companion.nanoseconds
4848
* [DateTimeUnit.MONTH], and others.
4949
*
5050
* Two ways are provided to create custom [DateTimeUnit] instances:
51-
* - By multiplying an existing unit on the right by an integer scalar: for example, `DateTimeUnit.MICROSECOND * 10`.
52-
* - By constructing an instance manually with [TimeBased], [DayBased], or [MonthBased]: for example,
51+
* - By multiplying an existing unit on the right by an integer scalar, for example, `DateTimeUnit.MICROSECOND * 10`.
52+
* - By constructing an instance manually with [TimeBased], [DayBased], or [MonthBased], for example,
5353
* `DateTimeUnit.TimeBased(nanoseconds = 10_000)`.
5454
*
5555
* Also, [DateTimeUnit] can be serialized and deserialized using `kotlinx.serialization`:
@@ -164,8 +164,8 @@ public sealed class DateTimeUnit {
164164
/**
165165
* A [date-time unit][DateTimeUnit] equal to some number of calendar days.
166166
*
167-
* A calendar day is not considered identical to 24 hours,
168-
* thus a `DayBased`-unit cannot be expressed as a multiple of some [TimeBased]-unit.
167+
* A calendar day is not considered identical to 24 hours.
168+
* Thus, a `DayBased` unit cannot be expressed as a multiple of some [TimeBased] unit.
169169
*
170170
* The reason lies in time zone transitions, because of which some days can be 23 or 25 hours.
171171
* For example, we say that exactly a whole day has passed between `2019-10-27T02:59` and `2019-10-28T02:59`
@@ -204,7 +204,8 @@ public sealed class DateTimeUnit {
204204
/**
205205
* A [date-time unit][DateTimeUnit] equal to some number of months.
206206
*
207-
* Since different months have different number of days, a `MonthBased`-unit cannot be expressed as a multiple of some [DayBased]-unit.
207+
* Since different months have a different number of days, a `MonthBased` unit cannot be expressed
208+
* as a multiple of some [DayBased]-unit.
208209
*
209210
* @see DateTimeUnit for a description of date-time units in general.
210211
* @sample kotlinx.datetime.test.samples.DateTimeUnitSamples.monthBasedUnit

core/common/src/Instant.kt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import kotlin.time.*
1515
/**
1616
* A moment in time.
1717
*
18-
* A point in time must be uniquely identified, so that it is independent of a time zone.
19-
* For example, `1970-01-01, 00:00:00` does not represent a moment in time, since this would happen at different times
20-
* in different time zones: someone in Tokyo would think its already `1970-01-01` several hours earlier than someone in
18+
* A point in time must be uniquely identified so that it is independent of a time zone.
19+
* For example, `1970-01-01, 00:00:00` does not represent a moment in time since this would happen at different times
20+
* in different time zones: someone in Tokyo would think it is already `1970-01-01` several hours earlier than someone in
2121
* Berlin would. To represent such entities, use [LocalDateTime].
2222
* In contrast, "the moment the clocks in London first showed 00:00 on Jan 1, 2000" is a specific moment
23-
* in time, as is "1970-01-01, 00:00:00 UTC+0", and so it can be represented as an [Instant].
23+
* in time, as is "1970-01-01, 00:00:00 UTC+0", so it can be represented as an [Instant].
2424
*
2525
* `Instant` uses the UTC-SLS (smeared leap second) time scale. This time scale doesn't contain instants
2626
* corresponding to leap seconds, but instead "smears" positive and negative leap seconds among the last 1000 seconds
@@ -46,7 +46,7 @@ import kotlin.time.*
4646
*
4747
* [Instant] is essentially the number of seconds and nanoseconds since a designated moment in time,
4848
* stored as something like `1709898983.123456789`.
49-
* [Instant] contains no information about what day or time it is, as this depends on the time zone.
49+
* [Instant] does not contain information about the day or time, as this depends on the time zone.
5050
* To work with this information for a specific time zone, obtain a [LocalDateTime] using [Instant.toLocalDateTime]:
5151
*
5252
* ```
@@ -98,16 +98,16 @@ import kotlin.time.*
9898
* Since [Instant] represents a point in time, it is always well-defined what the result of arithmetic operations on it
9999
* is, including the cases when a calendar is used.
100100
* This is not the case for [LocalDateTime], where the result of arithmetic operations depends on the time zone.
101-
* See the documentation of [LocalDateTime] for more details.
101+
* See the [LocalDateTime] documentation for more details.
102102
*
103103
* Adding and subtracting calendar-based units can be done using the [plus] and [minus] operators,
104104
* requiring a [TimeZone]:
105105
*
106106
* ```
107-
* // one day from now in Berlin
107+
* // One day from now in Berlin
108108
* Clock.System.now().plus(1, DateTimeUnit.DAY, TimeZone.of("Europe/Berlin"))
109109
*
110-
* // a day and two hours short from two months later in Berlin
110+
* // A day and two hours short from two months later in Berlin
111111
* Clock.System.now().plus(DateTimePeriod(months = 2, days = -1, hours = -2), TimeZone.of("Europe/Berlin"))
112112
* ```
113113
*
@@ -118,7 +118,7 @@ import kotlin.time.*
118118
* val start = Clock.System.now()
119119
* val concertStart = LocalDateTime(2023, 1, 1, 20, 0, 0).toInstant(TimeZone.of("Europe/Berlin"))
120120
* val timeUntilConcert = start.periodUntil(concertStart, TimeZone.of("Europe/Berlin"))
121-
* // two months, three days, four hours, and five minutes until the concert
121+
* // Two months, three days, four hours, and five minutes until the concert
122122
* ```
123123
*
124124
* or [Instant.until] method, as well as [Instant.daysUntil], [Instant.monthsUntil],
@@ -187,7 +187,7 @@ import kotlin.time.*
187187
* ```
188188
*
189189
* Additionally, there are several `kotlinx-serialization` serializers for [Instant]:
190-
* - [InstantIso8601Serializer] for the ISO 8601 extended format,
190+
* - [InstantIso8601Serializer] for the ISO 8601 extended format.
191191
* - [InstantComponentSerializer] for an object with components.
192192
*
193193
* @see LocalDateTime for a user-visible representation of moments in time in an unspecified time zone.
@@ -285,7 +285,7 @@ public expect class Instant : Comparable<Instant> {
285285

286286
/**
287287
* Compares `this` instant with the [other] instant.
288-
* Returns zero if this instant represents the same moment as the other (i.e., equal to other),
288+
* Returns zero if this instant represents the same moment as the other (i.e., when it's equal to other),
289289
* a negative number if this instant is earlier than the other,
290290
* and a positive number if this instant is later than the other.
291291
*
@@ -294,9 +294,9 @@ public expect class Instant : Comparable<Instant> {
294294
public override operator fun compareTo(other: Instant): Int
295295

296296
/**
297-
* Converts this instant to the ISO 8601 string representation; for example, `2023-01-02T23:40:57.120Z`
297+
* Converts this instant to the ISO 8601 string representation, for example, `2023-01-02T23:40:57.120Z`.
298298
*
299-
* The representation uses the UTC-SLS time scale, instead of UTC.
299+
* The representation uses the UTC-SLS time scale instead of UTC.
300300
* In practice, this means that leap second handling will not be readjusted to the UTC.
301301
* Leap seconds will not be added or skipped, so it is impossible to acquire a string
302302
* where the component for seconds is 60, and for any day, it's possible to observe 23:59:59.
@@ -480,9 +480,9 @@ public fun Instant.minus(period: DateTimePeriod, timeZone: TimeZone): Instant =
480480
* The components of [DateTimePeriod] are calculated so that adding it to `this` instant results in the [other] instant.
481481
*
482482
* All components of the [DateTimePeriod] returned are:
483-
* - positive or zero if this instant is earlier than the other,
484-
* - negative or zero if this instant is later than the other,
485-
* - exactly zero if this instant is equal to the other.
483+
* - Positive or zero if this instant is earlier than the other.
484+
* - Negative or zero if this instant is later than the other.
485+
* - Exactly zero if this instant is equal to the other.
486486
*
487487
* @throws DateTimeArithmeticException if `this` or [other] instant is too large to fit in [LocalDateTime].
488488
* Or (only on the JVM) if the number of months between the two dates exceeds an Int.
@@ -495,9 +495,9 @@ public expect fun Instant.periodUntil(other: Instant, timeZone: TimeZone): DateT
495495
* in the specified [timeZone].
496496
*
497497
* The value returned is:
498-
* - positive or zero if this instant is earlier than the other,
499-
* - negative or zero if this instant is later than the other,
500-
* - zero if this instant is equal to the other.
498+
* - Positive or zero if this instant is earlier than the other.
499+
* - Negative or zero if this instant is later than the other.
500+
* - Zero if this instant is equal to the other.
501501
*
502502
* If the result does not fit in [Long], returns [Long.MAX_VALUE] for a positive result or [Long.MIN_VALUE] for a negative result.
503503
*
@@ -510,9 +510,9 @@ public expect fun Instant.until(other: Instant, unit: DateTimeUnit, timeZone: Ti
510510
* Returns the whole number of the specified time [units][unit] between `this` and [other] instants.
511511
*
512512
* The value returned is:
513-
* - positive or zero if this instant is earlier than the other,
514-
* - negative or zero if this instant is later than the other,
515-
* - zero if this instant is equal to the other.
513+
* - Positive or zero if this instant is earlier than the other.
514+
* - Negative or zero if this instant is later than the other.
515+
* - Zero if this instant is equal to the other.
516516
*
517517
* If the result does not fit in [Long], returns [Long.MAX_VALUE] for a positive result or [Long.MIN_VALUE] for a negative result.
518518
*
@@ -570,9 +570,9 @@ public fun Instant.yearsUntil(other: Instant, timeZone: TimeZone): Int =
570570
* The components of [DateTimePeriod] are calculated so that adding it back to the `other` instant results in this instant.
571571
*
572572
* All components of the [DateTimePeriod] returned are:
573-
* - negative or zero if this instant is earlier than the other,
574-
* - positive or zero if this instant is later than the other,
575-
* - exactly zero if this instant is equal to the other.
573+
* - Negative or zero if this instant is earlier than the other.
574+
* - Positive or zero if this instant is later than the other.
575+
* - Exactly zero if this instant is equal to the other.
576576
*
577577
* @throws DateTimeArithmeticException if `this` or [other] instant is too large to fit in [LocalDateTime].
578578
* Or (only on the JVM) if the number of months between the two dates exceeds an Int.

0 commit comments

Comments
 (0)