Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,7 @@ export default {
|| this.getDateOfMessage(message1).format('YYYY-MM-DD') !== this.getDateOfMessage(message2).format('YYYY-MM-DD')
},

getRelativePrefix(date) {
const diffDays = moment().startOf('day').diff(date, 'days')
getRelativePrefix(date, diffDays) {
switch (diffDays) {
case 0:
return t('spreed', 'Today')
Expand All @@ -576,19 +575,20 @@ export default {
*/
generateDateSeparator(dateTimestamp) {
const date = moment.unix(dateTimestamp).startOf('day')
// <Today>, <March 18th, 2024>
// Relative date is only shown until a week ago
if (moment().startOf('day').diff(date, 'days') <= 7) {
const diffDays = moment().startOf('day').diff(date, 'days')
// Relative date is only shown up to a week ago (inclusive)
if (diffDays <= 7) {
// TRANSLATORS: <Today>, <March 18th, 2024>
return t('spreed', '{relativeDate}, {absoluteDate}', {
relativeDate: this.getRelativePrefix(date),
relativeDate: this.getRelativePrefix(date, diffDays),
// 'LL' formats a localized date including day of month, month
// name and year
absoluteDate: date.format('LL'),
}, undefined, {
escape: false, // French "Today" has a ' in it
})
} else {
// <March 18th, 2024>
// TRANSLATORS: <March 18th, 2024>
return t('spreed', '{absoluteDate}', { absoluteDate: date.format('LL') })
}

Expand Down