Mattermost-server: Messages posted today may appear as "Yesterday"

Created on 11 Nov 2020  路  7Comments  路  Source: mattermost/mattermost-server

Summary

In the following environment, the message posted today was sometimes displayed as "Yesterday".

  • JST (UTC+9) for both server and client PC time zones
  • "ExperimentalTimezone": false in config.json
  • Mattermost Version: Team Edition 5.28.1, Enterprise Edition (unlicensed) 5.29.0-rc2
  • Windows 10 + Firefox, Desktop App, Google Chrome

Steps to reproduce

Post a message between 00:00 and 09:00 JST in the above environment

Expected behavior

Posts at JST 07:00 (UTC 22:00) should be labeled "Today".

Observed behavior (that appears unintentional)

Posts at JST 07:00 (UTC 22:00) are labeled "Yesterday".

image

According to the content posted on Twitter by other Japanese user, "Yesterday" is displayed before JST 09:00 (UTC 00:00), and "Today" is displayed after that time.
(https://twitter.com/ken_kiku/status/1323061018004660225)

Possible fixes

As a workaround, setting ExperimentalTimezone to true will display it correctly.

Help Wanted

All 7 comments

Hey @maruTA-bis5, I think changing ExperimentalTimezone to true here will do the job. Can you please confirm so that I can go ahead and make the change? Thanks!

Also, @amyblais, can you assign this to me? :)

@amyblais, I am sorry for the trouble but can you tag someone who can confirm whether what I wrote above sounds good? Thank you!

@calebroseland Can you help with the question here https://github.com/mattermost/mattermost-server/issues/16259#issuecomment-726686534?

@haardikdharma10 ExperimentalTimezone: true will indeed fix this, but technically I believe it's a bug.

It seems like a discrepancy between the date-part ('Yesterday'/'Today') and the time-part.

The relative-time parsing in datetime.ts is explicitly UTC-based if no timezone is provided (e.g. ExperimentalTimezone: false), whereas the Date constructor used to parse the value in timestamp.tsx implicitly uses the client/browser timezone if no timezone is provided.

Maybe removing the explicitly-UTC there would do the trick? (not 100%; doing this might bring up other issues)

-    const momentA = moment.utc(a.getTime());
-    const momentB = moment.utc(b.getTime());
+    const momentA = moment(a);
+    const momentB = moment(b);

Downside is the tests and/or time mocks in timestamp.test.tsx would probably need to be updated, but given this issue/bug, a couple of the tests there are probably faulty anyway.

@calebroseland, thanks for the explanation. I appreciate your time:) I'll give it a go.

Was this page helpful?
0 / 5 - 0 ratings