@@ -18,10 +18,10 @@ import kotlinx.serialization.Serializable
18
18
* For example, `2020-08-30T18:43` is not a *moment in time*, since someone in Berlin and someone in Tokyo would witness
19
19
* this on their clocks at different times, but it is a [LocalDateTime].
20
20
*
21
- * The main purpose of this class is to provide human-readable representations of [Instant] values, or to transfer them
22
- * as data.
23
- * Instances of [LocalDateTime] should not be stored when a specific time zone is known: in this case, it is recommended
24
- * to use [Instant] instead.
21
+ * The main purpose of this class is to provide human-readable representations of [Instant] values, to transfer them
22
+ * as data, or to define future planned events that will have the same local date-time even if the time zone rules
23
+ * change.
24
+ * In all other cases when a specific time zone is known, it is recommended to use [Instant] instead.
25
25
*
26
26
* ### Arithmetic operations
27
27
*
@@ -30,7 +30,8 @@ import kotlinx.serialization.Serializable
30
30
*
31
31
* For example, in Berlin, naively adding one day to `2021-03-27T02:16:20` without accounting for the time zone would
32
32
* result in `2021-03-28T02:16:20`.
33
- * However, this local date-time is invalid, because the clocks moved forward from `02:00` to `03:00` on that day.
33
+ * However, the resulting local date-time cannot be observed in that time zone,
34
+ * because the clocks moved forward from `02:00` to `03:00` on that day.
34
35
* This is known as a "time gap", or a "spring forward" transition.
35
36
*
36
37
* Similarly, the local date-time `2021-10-31T02:16:20` is ambiguous,
@@ -39,8 +40,8 @@ import kotlinx.serialization.Serializable
39
40
*
40
41
* For these reasons, using [LocalDateTime] as an input to arithmetic operations is discouraged.
41
42
*
42
- * When only arithmetic on the date component is needed, without touching the time, use [LocalDate] instead,
43
- * as it provides well-defined date arithmetic.
43
+ * When only the date component is needed, without the time, use [LocalDate] instead.
44
+ * It provides well-defined date arithmetic.
44
45
*
45
46
* If the time component must be taken into account, [LocalDateTime]
46
47
* should be converted to [Instant] using a specific time zone, and the arithmetic on [Instant] should be used.
@@ -65,7 +66,8 @@ import kotlinx.serialization.Serializable
65
66
* whether the given date and time components are valid in the implied time zone.
66
67
* For example, `2021-03-28T02:16:20` is invalid in Berlin, as it falls into a time gap, but nothing prevents one
67
68
* from constructing such a [LocalDateTime].
68
- * Before constructing a [LocalDateTime] using any API, please ensure that the result is valid in the implied time zone.
69
+ * Before using a [LocalDateTime] constructed using any API,
70
+ * please ensure that the result is valid in the implied time zone.
69
71
* The recommended pattern is to convert a [LocalDateTime] to [Instant] as soon as possible (see
70
72
* [LocalDateTime.toInstant]) and work with [Instant] values instead.
71
73
*
0 commit comments