/** * @return True if we should revert the current dark. */ funcalculateAutoDarkChange( currentIsDark: Boolean, nowMilli: Long, lastLaunchMilli: Long ): Boolean { val lastLaunch = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastLaunchMilli), ZoneId.systemDefault()) val now = LocalDateTime.ofInstant(Instant.ofEpochMilli(nowMilli), ZoneId.systemDefault()) val today = LocalDate.now() val nightRange = scheduleRange val nightStart = LocalDateTime.of(today, LocalTime.of(nightRange.fromHour, nightRange.fromMinute)) val nightEnd = LocalDateTime.of(today, LocalTime.of(nightRange.toHour, nightRange.toMinute))
funisEnteringTheSpanFirst(from: LocalDateTime, to: LocalDateTime): Boolean { if (from == to) returnfalse require(from.isBefore(to)) return (now.isAfter(from) || now == from) && now.isBefore(to) && lastLaunch.isBefore(from) }