From 8b708e0eee915e15461bf01e3773f6a96a111800 Mon Sep 17 00:00:00 2001 From: Snowteamer <64228468+snowteamer@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:01:08 +0100 Subject: [PATCH] Fix issue #1789 (#1802) * Fix issue #1789 - wrong timeSince output * Use replaceAll with FlowFixMe * Remove renamed test file --- frontend/model/contracts/shared/time.js | 3 ++- frontend/model/contracts/shared/time.test.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/model/contracts/shared/time.js b/frontend/model/contracts/shared/time.js index d8674ff9b..ec8007549 100644 --- a/frontend/model/contracts/shared/time.js +++ b/frontend/model/contracts/shared/time.js @@ -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') diff --git a/frontend/model/contracts/shared/time.test.js b/frontend/model/contracts/shared/time.test.js index 1349e8caa..d97f36d74 100644 --- a/frontend/model/contracts/shared/time.test.js +++ b/frontend/model/contracts/shared/time.test.js @@ -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') }) })