Skip to content

Commit

Permalink
Address the review
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb committed Jan 22, 2025
1 parent 1249b7c commit 997a93f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
21 changes: 11 additions & 10 deletions core/commonJs/src/internal/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,23 @@ private val tzdb: Result<TimeZoneDatabase?> = runCatching {
}
/** converts a base60 number of minutes to a whole number of seconds */
fun base60MinutesInSeconds(string: String): Long {
var i = 0
var parts = string.split('.')
val parts = string.split('.')

// handle negative numbers
val sign = if (string.startsWith('-')) {
i = 1
-1
val sign: Int
val minuteNumberStart: Int
if (string.startsWith('-')) {
minuteNumberStart = 1
sign = -1
} else {
1
minuteNumberStart = 0
sign = 1
}

var wholeMinutes: Long = 0
val whole = parts[0]
// handle digits before the decimal (whole minutes)
for (ix in i..whole.lastIndex) {
wholeMinutes = 60 * wholeMinutes + charCodeToInt(whole[ix])
val whole = parts[0]
val wholeMinutes: Long = (minuteNumberStart..whole.lastIndex).map { charCodeToInt(whole[it]) }.fold(0L) {
acc, digit -> 60 * acc + digit
}

// handle digits after the decimal (seconds and less)
Expand Down
3 changes: 1 addition & 2 deletions core/commonKotlin/src/internal/MonthDayTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ internal interface DateOfYear {

/**
* The day of year, in the 0..365 range. During leap years, 29th February is counted as the 60th day of the year.
* The number 366 is not supported, as outside the leap years, there are only 365 days in a year.
*/
internal class JulianDayOfYear(val zeroBasedDayOfYear: Int) : DateOfYear {
init {
require(zeroBasedDayOfYear in 0..365) {
"Expected a value in 1..365 for the Julian day-of-year, but got $zeroBasedDayOfYear"
"Expected a value in 0..365 for the Julian day-of-year, but got $zeroBasedDayOfYear"
}
}
override fun toLocalDate(year: Int): LocalDate =
Expand Down

0 comments on commit 997a93f

Please sign in to comment.