Merge pull request #3332 from Isira-Seneviratne/formatRelativeTime

Use only the date in relative time formatting.
This commit is contained in:
Bnyro 2023-03-20 15:14:33 +01:00 committed by GitHub
commit 2cba327252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,8 +64,10 @@ object TextUtils {
} }
fun formatRelativeDate(context: Context, unixTime: Long): CharSequence { fun formatRelativeDate(context: Context, unixTime: Long): CharSequence {
// TODO: Use LocalDate.ofInstant() when it is available in SDK 34.
val date = LocalDateTime.ofInstant(Instant.ofEpochMilli(unixTime), ZoneId.systemDefault()) val date = LocalDateTime.ofInstant(Instant.ofEpochMilli(unixTime), ZoneId.systemDefault())
val now = LocalDateTime.now() .toLocalDate()
val now = java.time.LocalDate.now()
val weeks = date.until(now, ChronoUnit.WEEKS) val weeks = date.until(now, ChronoUnit.WEEKS)
return if (weeks > 0) { return if (weeks > 0) {