Revert to Java 8
This commit is contained in:
committed by
Koitharu
parent
004109a6bc
commit
3f2e32dcc2
@@ -48,11 +48,11 @@ android {
|
|||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
coreLibraryDesugaringEnabled true
|
coreLibraryDesugaringEnabled true
|
||||||
sourceCompatibility JavaVersion.VERSION_17
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_17
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_17
|
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||||
freeCompilerArgs += [
|
freeCompilerArgs += [
|
||||||
'-opt-in=kotlin.ExperimentalStdlibApi',
|
'-opt-in=kotlin.ExperimentalStdlibApi',
|
||||||
'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
|
'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ sealed class DateTimeAgo {
|
|||||||
|
|
||||||
data class Absolute(private val date: LocalDate) : DateTimeAgo() {
|
data class Absolute(private val date: LocalDate) : DateTimeAgo() {
|
||||||
override fun format(resources: Resources): String {
|
override fun format(resources: Resources): String {
|
||||||
return if (date == LocalDate.EPOCH) {
|
return if (date == EPOCH_DATE) {
|
||||||
resources.getString(R.string.unknown)
|
resources.getString(R.string.unknown)
|
||||||
} else {
|
} else {
|
||||||
date.format(formatter)
|
date.format(formatter)
|
||||||
@@ -85,6 +85,8 @@ sealed class DateTimeAgo {
|
|||||||
override fun toString() = "abs_${date.toEpochDay()}"
|
override fun toString() = "abs_${date.toEpochDay()}"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
// TODO: Use Java 9's LocalDate.EPOCH.
|
||||||
|
private val EPOCH_DATE = LocalDate.of(1970, 1, 1)
|
||||||
private val formatter = DateTimeFormatter.ofPattern("d MMMM")
|
private val formatter = DateTimeFormatter.ofPattern("d MMMM")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package org.koitharu.kotatsu.core.util.ext
|
|||||||
import org.koitharu.kotatsu.core.ui.model.DateTimeAgo
|
import org.koitharu.kotatsu.core.ui.model.DateTimeAgo
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.temporal.ChronoUnit
|
import java.time.temporal.ChronoUnit
|
||||||
|
|
||||||
fun calculateTimeAgo(instant: Instant, showMonths: Boolean = false): DateTimeAgo {
|
fun calculateTimeAgo(instant: Instant, showMonths: Boolean = false): DateTimeAgo {
|
||||||
val localDate = LocalDate.ofInstant(instant, ZoneId.systemDefault())
|
// TODO: Use Java 9's LocalDate.ofInstant().
|
||||||
|
val localDate = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate()
|
||||||
val now = LocalDate.now()
|
val now = LocalDate.now()
|
||||||
val diffDays = localDate.until(now, ChronoUnit.DAYS)
|
val diffDays = localDate.until(now, ChronoUnit.DAYS)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user