@@ -58,7 +58,7 @@ import kotlinx.serialization.Serializable
5858 * @sample kotlinx.datetime.test.samples.YearMonthSamples.customFormat 
5959 */  
6060@Serializable(with =  YearMonthIso8601Serializer ::class )
61- public  class  YearMonth 
61+ public  expect   class  YearMonth 
6262/* *
6363 * Constructs a [YearMonth] instance from the given year-month components. 
6464 * 
@@ -78,49 +78,37 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
7878     * 
7979     * @sample kotlinx.datetime.test.samples.YearMonthSamples.year 
8080     */  
81-     public  val  year:  Int  =  year
82- 
83-     /* *
84-      * Returns the number-of-the-month (1..12) component of the year-month. 
85-      * 
86-      * Shortcut for `month.number`. 
87-      */  
88-     internal  val  monthNumber:  Int  =  month
89- 
90-     init  {
91-         require(month in  1 .. 12 ) { " Month must be in 1..12, but was $month "   }
92-         require(year in  LocalDate .MIN .year.. LocalDate .MAX .year) {
93-             " Year $year  is out of range: ${LocalDate .MIN .year} ..${LocalDate .MAX .year} " 
94-         }
95-     }
81+     public  val  year:  Int 
9682
9783    /* *
9884     * Returns the month ([Month]) component of the year-month. 
9985     * 
10086     * @sample kotlinx.datetime.test.samples.YearMonthSamples.month 
10187     */  
102-     public  val  month:  Month  get()  =   Month (monthNumber) 
88+     public  val  month:  Month 
10389
10490    /* *
10591     * Returns the first day of the year-month. 
10692     * 
10793     * @sample kotlinx.datetime.test.samples.YearMonthSamples.firstAndLastDay 
10894     */  
109-     public  val  firstDay:  LocalDate  get()  =  onDay( 1 ) 
95+     public  val  firstDay:  LocalDate 
11096
11197    /* *
11298     * Returns the last day of the year-month. 
11399     * 
114100     * @sample kotlinx.datetime.test.samples.YearMonthSamples.firstAndLastDay 
115101     */  
116-     public  val  lastDay:  LocalDate  get()  =  onDay(numberOfDays) 
102+     public  val  lastDay:  LocalDate 
117103
118104    /* *
119105     * Returns the number of days in the year-month. 
120106     * 
121107     * @sample kotlinx.datetime.test.samples.YearMonthSamples.numberOfDays 
122108     */  
123-     public  val  numberOfDays:  Int  get() =  monthNumber.monthLength(isLeapYear(year))
109+     public  val  numberOfDays:  Int 
110+ 
111+     internal  val  monthNumber:  Int 
124112
125113    /* *
126114     * Returns the range of days in the year-month. 
@@ -138,7 +126,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
138126     * @throws IllegalArgumentException if [year] is out of range. 
139127     * @sample kotlinx.datetime.test.samples.YearMonthSamples.constructorFunction 
140128     */  
141-     public  constructor (year:  Int , month:  Month ):   this (year, month.number) 
129+     public  constructor (year:  Int , month:  Month )
142130
143131    public  companion  object  {
144132        /* *
@@ -155,8 +143,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
155143         * @see YearMonth.format for formatting using a custom format. 
156144         * @sample kotlinx.datetime.test.samples.YearMonthSamples.parsing 
157145         */  
158-         public  fun  parse (input :  CharSequence , format :  DateTimeFormat <YearMonth > = Formats .ISO ): YearMonth  = 
159-             format.parse(input)
146+         public  fun  parse (input :  CharSequence , format :  DateTimeFormat <YearMonth > = Formats .ISO ): YearMonth 
160147
161148        /* *
162149         * Creates a new format for parsing and formatting [YearMonth] values. 
@@ -167,8 +154,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
167154         * @sample kotlinx.datetime.test.samples.YearMonthSamples.customFormat 
168155         */  
169156        @Suppress(" FunctionName"  )
170-         public  fun  Format (block :  DateTimeFormatBuilder .WithYearMonth .() ->  Unit ): DateTimeFormat <YearMonth > = 
171-             YearMonthFormat .build(block)
157+         public  fun  Format (block :  DateTimeFormatBuilder .WithYearMonth .() ->  Unit ): DateTimeFormat <YearMonth >
172158    }
173159
174160    /* *
@@ -194,9 +180,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
194180         * 
195181         * @sample kotlinx.datetime.test.samples.YearMonthSamples.Formats.iso 
196182         */  
197-         public  val  ISO :  DateTimeFormat <YearMonth > =  YearMonthFormat .build {
198-             year(); char(' -'  ); monthNumber()
199-         }
183+         public  val  ISO :  DateTimeFormat <YearMonth >
200184    }
201185
202186    /* *
@@ -207,7 +191,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
207191     * 
208192     * @sample kotlinx.datetime.test.samples.YearMonthSamples.compareToSample 
209193     */  
210-     override  fun  compareTo (other :  YearMonth ): Int   =  compareValuesBy( this , other,  YearMonth ::year,  YearMonth ::month) 
194+     override  fun  compareTo (other :  YearMonth ): Int 
211195
212196    /* *
213197     * Converts this year-month to the extended ISO 8601 string representation. 
@@ -217,17 +201,7 @@ public constructor(year: Int, month: Int) : Comparable<YearMonth> {
217201     * @see YearMonth.format for formatting using a custom format. 
218202     * @sample kotlinx.datetime.test.samples.YearMonthSamples.toStringSample 
219203     */  
220-     override  fun  toString (): String  =  Formats .ISO .format(this )
221- 
222-     /* *
223-      * @suppress 
224-      */  
225-     override  fun  equals (other :  Any? ): Boolean  =  other is  YearMonth  &&  year ==  other.year &&  month ==  other.month
226- 
227-     /* *
228-      * @suppress 
229-      */  
230-     override  fun  hashCode (): Int  =  year *  31  +  month.hashCode()
204+     override  fun  toString (): String 
231205}
232206
233207/* *
0 commit comments