Skip to content

Commit

Permalink
Merge pull request #11837 from nextcloud/fix/noid/relative-date-in-da…
Browse files Browse the repository at this point in the history
…te-separators

Fix(MessagesList): Limit relative date up to a week.
  • Loading branch information
nickvergessen authored Mar 18, 2024
2 parents 240065f + 30af508 commit dd0ce1a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,10 @@ export default {
return t('spreed', 'Today')
case 1:
return t('spreed', 'Yesterday')
case 7:
return t('spreed', 'A week ago')
default:
return t('spreed', '{n} days ago', { n: diffDays })
return n('spreed', '%n day ago', '%n days ago', diffDays)
}
},

Expand All @@ -574,15 +576,22 @@ export default {
*/
generateDateSeparator(dateTimestamp) {
const date = moment.unix(dateTimestamp).startOf('day')
// <Today>, <November 11th, 2019>
return t('spreed', '{relativeDate}, {absoluteDate}', {
relativeDate: this.getRelativePrefix(date),
// '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
})
// <Today>, <March 18th, 2024>
// Relative date is only shown until a week ago
if (moment().startOf('day').diff(date, 'days') <= 7) {
return t('spreed', '{relativeDate}, {absoluteDate}', {
relativeDate: this.getRelativePrefix(date),
// '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>
return t('spreed', '{absoluteDate}', { absoluteDate: date.format('LL') })
}

},

/**
Expand Down

0 comments on commit dd0ce1a

Please sign in to comment.