File tree 2 files changed +12
-12
lines changed
commonKotlin/src/internal 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -25,22 +25,23 @@ private val tzdb: Result<TimeZoneDatabase?> = runCatching {
25
25
}
26
26
/* * converts a base60 number of minutes to a whole number of seconds */
27
27
fun base60MinutesInSeconds (string : String ): Long {
28
- var i = 0
29
- var parts = string.split(' .' )
28
+ val parts = string.split(' .' )
30
29
31
30
// handle negative numbers
32
- val sign = if (string.startsWith(' -' )) {
33
- i = 1
34
- - 1
31
+ val sign: Int
32
+ val minuteNumberStart: Int
33
+ if (string.startsWith(' -' )) {
34
+ minuteNumberStart = 1
35
+ sign = - 1
35
36
} else {
36
- 1
37
+ minuteNumberStart = 0
38
+ sign = 1
37
39
}
38
40
39
- var wholeMinutes: Long = 0
40
- val whole = parts[0 ]
41
41
// handle digits before the decimal (whole minutes)
42
- for (ix in i.. whole.lastIndex) {
43
- wholeMinutes = 60 * wholeMinutes + charCodeToInt(whole[ix])
42
+ val whole = parts[0 ]
43
+ val wholeMinutes: Long = (minuteNumberStart.. whole.lastIndex).map { charCodeToInt(whole[it]) }.fold(0L ) {
44
+ acc, digit -> 60 * acc + digit
44
45
}
45
46
46
47
// handle digits after the decimal (seconds and less)
Original file line number Diff line number Diff line change @@ -28,12 +28,11 @@ internal interface DateOfYear {
28
28
29
29
/* *
30
30
* The day of year, in the 0..365 range. During leap years, 29th February is counted as the 60th day of the year.
31
- * The number 366 is not supported, as outside the leap years, there are only 365 days in a year.
32
31
*/
33
32
internal class JulianDayOfYear (val zeroBasedDayOfYear : Int ) : DateOfYear {
34
33
init {
35
34
require(zeroBasedDayOfYear in 0 .. 365 ) {
36
- " Expected a value in 1 ..365 for the Julian day-of-year, but got $zeroBasedDayOfYear "
35
+ " Expected a value in 0 ..365 for the Julian day-of-year, but got $zeroBasedDayOfYear "
37
36
}
38
37
}
39
38
override fun toLocalDate (year : Int ): LocalDate =
You can’t perform that action at this time.
0 commit comments