Skip to content

Commit 1493092

Browse files
committed
Fixes
1 parent b45f915 commit 1493092

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ collection of all datetime fields, can be used instead.
287287
```kotlin
288288
// import kotlinx.datetime.format.*
289289

290-
val monthDay = DateTimeComponents.Format { monthNumber(); char('/'); dayOfMonth() }
290+
val monthDay = DateTimeComponents.Format { monthNumber(); char('/'); day() }
291291
.parse("12/25")
292-
println(monthDay.dayOfMonth) // 25
292+
println(monthDay.day) // 25
293293
println(monthDay.monthNumber) // 12
294294

295295
val dateTimeOffset = DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET

core/common/src/YearMonth.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlinx.datetime.serializers.*
1111
import kotlinx.serialization.Serializable
1212

1313
/**
14-
* The year-month part of [LocalDate], without the day-of-month.
14+
* The year-month part of [LocalDate], without a day-of-month.
1515
*
1616
* This class represents years and months without a reference to a particular time zone.
1717
* As such, these objects may denote different time intervals in different time zones: for someone in Berlin,
@@ -50,6 +50,7 @@ import kotlinx.serialization.Serializable
5050
* See sample 3.
5151
*
5252
* Additionally, there are several `kotlinx-serialization` serializers for [YearMonth]:
53+
* - The default serializer, delegating to [toString] and [parse].
5354
* - [YearMonthIso8601Serializer] for the ISO 8601 extended format.
5455
* - [YearMonthComponentSerializer] for an object with components.
5556
*
@@ -65,7 +66,7 @@ public expect class YearMonth
6566
* The [month] component is 1-based.
6667
*
6768
* The supported ranges of components:
68-
* - [year] the range is platform-dependent, but at least is enough to represent year-months of all instants between
69+
* - [year] the range is unspecified, but at least is enough to represent year-months of all instants between
6970
* [Instant.DISTANT_PAST] and [Instant.DISTANT_FUTURE] in any time zone.
7071
* - [month] `1..12`
7172
*
@@ -120,7 +121,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
120121
/**
121122
* Constructs a [YearMonth] instance from the given year-month components.
122123
*
123-
* The range for [year] is platform-dependent, but at least is enough to represent year-months of all instants
124+
* The range for [year] is unspecified, but at least is enough to represent year-months of all instants
124125
* between [Instant.DISTANT_PAST] and [Instant.DISTANT_FUTURE] in any time zone.
125126
*
126127
* @throws IllegalArgumentException if [year] is out of range.
@@ -380,7 +381,6 @@ internal fun YearMonth.Companion.fromProlepticMonth(prolepticMonth: Long): YearM
380381
"Year $year is out of range: ${LocalDate.MIN.year}..${LocalDate.MAX.year}"
381382
}
382383
val month = prolepticMonth.mod(12) + 1
383-
println("proleptic month: ${prolepticMonth}, year: $year, month: $month")
384384
return YearMonth(year.toInt(), month)
385385
}
386386

core/common/test/ReadmeTest.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ class ReadmeTest {
4444
val knownDate = LocalDate(2020, 2, 21)
4545
}
4646

47+
@Test
48+
fun testObtainingYearMonth() {
49+
val day = LocalDate(2020, 2, 21)
50+
val yearMonth: YearMonth = day.yearMonth
51+
assertEquals(2020, yearMonth.year)
52+
assertEquals(2, yearMonth.monthNumber)
53+
}
54+
55+
4756
@Test
4857
fun testGettingLocalTimeComponents() {
4958
val now: Instant = Clock.System.now()
@@ -117,9 +126,9 @@ class ReadmeTest {
117126

118127
@Test
119128
fun testParsingAndFormattingPartialCompoundOrOutOfBoundsData() {
120-
val monthDay = DateTimeComponents.Format { monthNumber(); char('/'); dayOfMonth() }
129+
val monthDay = DateTimeComponents.Format { monthNumber(); char('/'); day() }
121130
.parse("12/25")
122-
assertEquals(25, monthDay.dayOfMonth)
131+
assertEquals(25, monthDay.day)
123132
assertEquals(12, monthDay.monthNumber)
124133

125134
val dateTimeOffset = DateTimeComponents.Formats.ISO_DATE_TIME_OFFSET

0 commit comments

Comments
 (0)