Date api issues.
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
aminecmi 2022-10-29 13:50:00 +02:00
parent 62ad1f45ba
commit 131101d2ee

View File

@ -16,10 +16,18 @@ actual class DateUtils actual constructor(actual val appSettingsService: AppSett
val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss" val FORMATTERV1 = "yyyy-MM-dd HH:mm:ss"
return if (appSettingsService.getApiVersion() >= 4) { return if (appSettingsService.getApiVersion() >= 4) {
OffsetDateTime.parse(dateString).toInstant().toEpochMilli() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
OffsetDateTime.parse(dateString).toInstant().toEpochMilli()
} else {
TODO("VERSION.SDK_INT < O")
}
} else { } else {
LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant( if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ZoneOffset.UTC).toEpochMilli() LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(FORMATTERV1)).toInstant(
ZoneOffset.UTC).toEpochMilli()
} else {
TODO("VERSION.SDK_INT < O")
}
} }
} }
@ -27,11 +35,15 @@ actual class DateUtils actual constructor(actual val appSettingsService: AppSett
val date = parseDate(dateString) val date = parseDate(dateString)
return " " + DateUtils.getRelativeTimeSpanString( return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
date, " " + DateUtils.getRelativeTimeSpanString(
Instant.now().toEpochMilli(), date,
DateUtils.MINUTE_IN_MILLIS, Instant.now().toEpochMilli(),
DateUtils.FORMAT_ABBREV_RELATIVE DateUtils.MINUTE_IN_MILLIS,
) DateUtils.FORMAT_ABBREV_RELATIVE
)
} else {
TODO("VERSION.SDK_INT < O")
}
} }
} }