@@ -11,10 +11,10 @@ import kotlinx.datetime.internal.format.parser.Copyable
1111import kotlin.math.*
1212
1313internal interface UtcOffsetFieldContainer {
14- var isNegative : Boolean?
15- var totalHoursAbs : Int?
16- var minutesOfHour : Int?
17- var secondsOfMinute : Int?
14+ var offsetIsNegative : Boolean?
15+ var offsetHours : Int?
16+ var offsetMinutesOfHour : Int?
17+ var offsetSecondsOfMinute : Int?
1818}
1919
2020internal interface AbstractWithOffsetBuilder : DateTimeFormatBuilder .WithUtcOffset {
@@ -127,26 +127,26 @@ internal fun DateTimeFormatBuilder.WithUtcOffset.isoOffset(
127127
128128private object OffsetFields {
129129 private val sign = object : FieldSign <UtcOffsetFieldContainer > {
130- override val isNegative = PropertyAccessor (UtcOffsetFieldContainer ::isNegative )
130+ override val isNegative = PropertyAccessor (UtcOffsetFieldContainer ::offsetIsNegative )
131131 override fun isZero (obj : UtcOffsetFieldContainer ): Boolean =
132- (obj.totalHoursAbs ? : 0 ) == 0 && (obj.minutesOfHour ? : 0 ) == 0 && (obj.secondsOfMinute ? : 0 ) == 0
132+ (obj.offsetHours ? : 0 ) == 0 && (obj.offsetMinutesOfHour ? : 0 ) == 0 && (obj.offsetSecondsOfMinute ? : 0 ) == 0
133133 }
134134 val totalHoursAbs = UnsignedFieldSpec (
135- PropertyAccessor (UtcOffsetFieldContainer ::totalHoursAbs ),
135+ PropertyAccessor (UtcOffsetFieldContainer ::offsetHours ),
136136 defaultValue = 0 ,
137137 minValue = 0 ,
138138 maxValue = 18 ,
139139 sign = sign,
140140 )
141141 val minutesOfHour = UnsignedFieldSpec (
142- PropertyAccessor (UtcOffsetFieldContainer ::minutesOfHour ),
142+ PropertyAccessor (UtcOffsetFieldContainer ::offsetMinutesOfHour ),
143143 defaultValue = 0 ,
144144 minValue = 0 ,
145145 maxValue = 59 ,
146146 sign = sign,
147147 )
148148 val secondsOfMinute = UnsignedFieldSpec (
149- PropertyAccessor (UtcOffsetFieldContainer ::secondsOfMinute ),
149+ PropertyAccessor (UtcOffsetFieldContainer ::offsetSecondsOfMinute ),
150150 defaultValue = 0 ,
151151 minValue = 0 ,
152152 maxValue = 59 ,
@@ -155,39 +155,39 @@ private object OffsetFields {
155155}
156156
157157internal class IncompleteUtcOffset (
158- override var isNegative : Boolean? = null ,
159- override var totalHoursAbs : Int? = null ,
160- override var minutesOfHour : Int? = null ,
161- override var secondsOfMinute : Int? = null ,
158+ override var offsetIsNegative : Boolean? = null ,
159+ override var offsetHours : Int? = null ,
160+ override var offsetMinutesOfHour : Int? = null ,
161+ override var offsetSecondsOfMinute : Int? = null ,
162162) : UtcOffsetFieldContainer, Copyable<IncompleteUtcOffset> {
163163
164164 fun toUtcOffset (): UtcOffset {
165- val sign = if (isNegative == true ) - 1 else 1
165+ val sign = if (offsetIsNegative == true ) - 1 else 1
166166 return UtcOffset (
167- totalHoursAbs ?.let { it * sign }, minutesOfHour ?.let { it * sign }, secondsOfMinute ?.let { it * sign }
167+ offsetHours ?.let { it * sign }, offsetMinutesOfHour ?.let { it * sign }, offsetSecondsOfMinute ?.let { it * sign }
168168 )
169169 }
170170
171171 fun populateFrom (offset : UtcOffset ) {
172- isNegative = offset.totalSeconds < 0
172+ offsetIsNegative = offset.totalSeconds < 0
173173 val totalSecondsAbs = offset.totalSeconds.absoluteValue
174- totalHoursAbs = totalSecondsAbs / 3600
175- minutesOfHour = (totalSecondsAbs / 60 ) % 60
176- secondsOfMinute = totalSecondsAbs % 60
174+ offsetHours = totalSecondsAbs / 3600
175+ offsetMinutesOfHour = (totalSecondsAbs / 60 ) % 60
176+ offsetSecondsOfMinute = totalSecondsAbs % 60
177177 }
178178
179179 override fun equals (other : Any? ): Boolean =
180- other is IncompleteUtcOffset && isNegative == other.isNegative && totalHoursAbs == other.totalHoursAbs &&
181- minutesOfHour == other.minutesOfHour && secondsOfMinute == other.secondsOfMinute
180+ other is IncompleteUtcOffset && offsetIsNegative == other.offsetIsNegative && offsetHours == other.offsetHours &&
181+ offsetMinutesOfHour == other.offsetMinutesOfHour && offsetSecondsOfMinute == other.offsetSecondsOfMinute
182182
183183 override fun hashCode (): Int =
184- isNegative .hashCode() + totalHoursAbs .hashCode() + minutesOfHour .hashCode() + secondsOfMinute .hashCode()
184+ offsetIsNegative .hashCode() + offsetHours .hashCode() + offsetMinutesOfHour .hashCode() + offsetSecondsOfMinute .hashCode()
185185
186186 override fun copy (): IncompleteUtcOffset =
187- IncompleteUtcOffset (isNegative, totalHoursAbs, minutesOfHour, secondsOfMinute )
187+ IncompleteUtcOffset (offsetIsNegative, offsetHours, offsetMinutesOfHour, offsetSecondsOfMinute )
188188
189189 override fun toString (): String =
190- " ${isNegative ?.let { if (it) " -" else " +" } ? : " " }${totalHoursAbs ? : " ??" } :${minutesOfHour ? : " ??" } :${secondsOfMinute ? : " ??" } "
190+ " ${offsetIsNegative ?.let { if (it) " -" else " +" } ? : " " }${offsetHours ? : " ??" } :${offsetMinutesOfHour ? : " ??" } :${offsetSecondsOfMinute ? : " ??" } "
191191}
192192
193193internal class UtcOffsetWholeHoursDirective (private val padding : Padding ) :
0 commit comments