Use only the date in relative time formatting.

This commit is contained in:
Isira Seneviratne 2023-03-20 08:47:14 +05:30
parent 7d216cd9fa
commit 21eae99eae

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) {