mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #3332 from Isira-Seneviratne/formatRelativeTime
Use only the date in relative time formatting.
This commit is contained in:
commit
2cba327252
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user