Skip to content

Commit

Permalink
Math fix for duration
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Jun 2, 2022
1 parent 24f4c6e commit 8b35652
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/com/cognifide/gradle/common/utils/Formats.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import java.time.LocalDateTime
import java.time.ZoneId
import java.time.temporal.ChronoUnit
import java.util.*
import kotlin.math.abs

@Suppress("MagicNumber", "TooManyFunctions")
object Formats {
Expand Down Expand Up @@ -260,7 +261,7 @@ object Formats {
fun durationFit(timestamp: Long, timestampZoneId: ZoneId, durationMillis: Long): Boolean {
val nowDate = LocalDateTime.now().atZone(timestampZoneId)
val timestampDate = localDateTimeAt(timestamp, timestampZoneId)
val diffMillis = ChronoUnit.MILLIS.between(timestampDate, nowDate)
val diffMillis = abs(ChronoUnit.MILLIS.between(timestampDate, nowDate))

return diffMillis < durationMillis
}
Expand Down

0 comments on commit 8b35652

Please sign in to comment.