Skip to content

Commit

Permalink
Fix issue #1789 (#1802)
Browse files Browse the repository at this point in the history
* Fix issue #1789 - wrong timeSince output

* Use replaceAll with FlowFixMe

* Remove renamed test file
  • Loading branch information
snowteamer authored Jan 11, 2024
1 parent bba9016 commit 8b708e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion frontend/model/contracts/shared/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ export function timeSince (datems: number, dateNow: number = Date.now()): string

if (interval >= DAYS_MILLIS * 2) {
// Make sure to replace any ordinary space character by a non-breaking one.
return humanDate(datems).replace(/\x32/g, '\xa0')
// $FlowFixMe
return humanDate(datems).replaceAll(' ', '\xa0')
}
if (interval >= DAYS_MILLIS) {
return L('1d')
Expand Down
4 changes: 2 additions & 2 deletions frontend/model/contracts/shared/time.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ describe('timeSince', function () {
)).equal('1d')
})

it('should return current day when +48h have passed', () => {
it('should return current day (with non-breaking space) when +48h have passed', () => {
should(timeSince(
currentDate - DAYS_MILLIS * 23,
currentDate
)).equal('May 7')
)).equal('May\xa07')
})
})

0 comments on commit 8b708e0

Please sign in to comment.