From a2e6d1553cb063df2baec7dc0ab687853e285451 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 25 Sep 2024 10:55:11 +0300 Subject: [PATCH] note date yesterday --- client/src/views/fields/datetime-short.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/src/views/fields/datetime-short.js b/client/src/views/fields/datetime-short.js index 0ea4d904ae..ec30fe38b2 100644 --- a/client/src/views/fields/datetime-short.js +++ b/client/src/views/fields/datetime-short.js @@ -65,6 +65,17 @@ class DatetimeShortFieldView extends DatetimeFieldView { const m = this.getDateTime().toMoment(value); const now = moment().tz(this.getDateTime().timeZone || 'UTC'); + const dt = now.clone().startOf('day'); + + const ranges = { + 'today': [dt.unix(), dt.add(1, 'days').unix()], + 'tomorrow': [dt.unix(), dt.add(1, 'days').unix()], + 'yesterday': [dt.add(-3, 'days').unix(), dt.add(1, 'days').unix()] + }; + + if (m.unix() > ranges['yesterday'][0] && m.unix() < ranges['yesterday'][1]) { + return this.translate('Yesterday') + ' ' + m.format(timeFormat); + } if ( m.unix() > now.clone().startOf('day').unix() &&