File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,14 @@ public class DateTimeComponents internal constructor(internal val contents: Date
274
274
275
275
/* *
276
276
* The month ([Month]) component of the date.
277
+ *
278
+ * This is a view of [monthNumber].
279
+ * Setting it will set [monthNumber], and getting it will return a [Month] instance if [monthNumber] is a valid
280
+ * month.
281
+ *
277
282
* @throws IllegalArgumentException during getting if [monthNumber] is outside the `1..12` range.
278
283
* @sample kotlinx.datetime.test.samples.format.DateTimeComponentsSamples.date
284
+ * @sample kotlinx.datetime.test.samples.format.DateTimeComponentsSamples.setMonth
279
285
*/
280
286
public var month: Month ?
281
287
get() = monthNumber?.let { Month (it) }
Original file line number Diff line number Diff line change @@ -155,6 +155,17 @@ class DateTimeComponentsSamples {
155
155
check(parsedDate.dayOfWeek == null )
156
156
}
157
157
158
+ @Test
159
+ fun setMonth () {
160
+ val input = " Mon, 30 Jul 2008 11:05:30 GMT"
161
+ val parsed = DateTimeComponents .Formats .RFC_1123 .parse(input)
162
+ check(parsed.monthNumber == 7 )
163
+ check(parsed.month == Month .JULY )
164
+ parsed.month = Month .JUNE
165
+ check(parsed.monthNumber == 6 )
166
+ check(parsed.month == Month .JUNE )
167
+ }
168
+
158
169
@Test
159
170
fun timeAmPm () {
160
171
val format = DateTimeComponents .Format {
You can’t perform that action at this time.
0 commit comments