mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Fixes #2679 - Timestamps in room list inconsistently use absolute and relative formatting
This commit is contained in:
committed by
Stefan Ceriu
parent
834260c144
commit
4a9de65030
@@ -26,7 +26,8 @@ extension Date {
|
|||||||
return formatted(date: .omitted, time: .shortened)
|
return formatted(date: .omitted, time: .shortened)
|
||||||
} else if calendar.isDateInYesterday(self) {
|
} else if calendar.isDateInYesterday(self) {
|
||||||
// Simply "Yesterday" if it was yesterday.
|
// Simply "Yesterday" if it was yesterday.
|
||||||
return formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence))
|
guard let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: Date()) else { fatalError() }
|
||||||
|
return yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence))
|
||||||
} else if let sixDaysAgo = calendar.date(byAdding: .day, value: -6, to: calendar.startOfDay(for: .now)),
|
} else if let sixDaysAgo = calendar.date(byAdding: .day, value: -6, to: calendar.startOfDay(for: .now)),
|
||||||
sixDaysAgo <= self {
|
sixDaysAgo <= self {
|
||||||
// The named day if it was in the last 6 days.
|
// The named day if it was in the last 6 days.
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
return firstTimestamp > secondTimestamp
|
return firstTimestamp > secondTimestamp
|
||||||
}
|
}
|
||||||
.map { key, receipt in
|
.map { key, receipt in
|
||||||
ReadReceipt(userID: key, formattedTimestamp: receipt.dateTimestamp?.formatted(date: .omitted, time: .shortened))
|
ReadReceipt(userID: key, formattedTimestamp: receipt.dateTimestamp?.formattedMinimal())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ class DateTests: XCTestCase {
|
|||||||
let yesterday = calendar.date(byAdding: .hour, value: 1, to: startOfYesterday)!
|
let yesterday = calendar.date(byAdding: .hour, value: 1, to: startOfYesterday)!
|
||||||
XCTAssertEqual(yesterday.formattedMinimal(), yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence)))
|
XCTAssertEqual(yesterday.formattedMinimal(), yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence)))
|
||||||
|
|
||||||
|
let nearYesterday = calendar.date(byAdding: DateComponents(hour: -10), to: today)!
|
||||||
|
XCTAssertEqual(nearYesterday.formattedMinimal(), yesterday.formatted(Date.RelativeFormatStyle(presentation: .named, capitalizationContext: .beginningOfSentence)))
|
||||||
|
|
||||||
let threeDaysAgo = calendar.date(byAdding: .day, value: -3, to: startOfToday)!
|
let threeDaysAgo = calendar.date(byAdding: .day, value: -3, to: startOfToday)!
|
||||||
XCTAssertEqual(threeDaysAgo.formattedMinimal(), threeDaysAgo.formatted(.dateTime.weekday(.wide)))
|
XCTAssertEqual(threeDaysAgo.formattedMinimal(), threeDaysAgo.formatted(.dateTime.weekday(.wide)))
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Timestamps in room list inconsistently use absolute and relative formatting
|
||||||
Reference in New Issue
Block a user