Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSC3160: Message timezone markup #3160

Open
wants to merge 18 commits into
base: old_master
Choose a base branch
from
Open
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions proposals/3160-message-timezone-markup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# MSC3160: Attach timezone metadata to time information in messages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cautionary tale about timezones: https://www.youtube.com/watch?v=-5wpm-gesOY

I strongly recommend that we do not mess with timezones at all and do not merge this MSC. The UI proposes hyperlinking text like "3pm tomorrow" in a <time> tag which contains the time + timezone. If we absolutely must do this I would much prefer if the onus was on the client to convert "3pm tomorrow" to the equivalent unix timestamp then send that, which then puts the onus on the receiver to convert back to a date/time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert "3pm tomorrow" to the equivalent unix timestamp then send that

Isn't that essentially what's proposed here, except it's an ISO 8601 timestamp instead of Unix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't we use unix timestamps as-is as per everything else in Matrix? E.g Devices last_seen_ts, notification ts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTML spec doesn't allow unix timestamps in the datetime attribute, so we'd probably have to use a custom attribute for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the sending client should convert to a reference time, ISO 8601 UTC is just as good a reference as unix (better in many ways, as you could display it to a human).

This comment was marked as off-topic.


When communicating across timezones, you sometimes want to agree on a time with others, for example when to have a meeting. If somebody says, let's meet at 8pm, everybody else in the room has to think in what timezone the other person is, and work out the math in their head how that relates to their timezone, if different.
bwindels marked this conversation as resolved.
Show resolved Hide resolved

Luckily, computers are great at math, and so to facilitate this, clients could allow to represent a point in time with special markup in a message, adding the timezone of the sender. The clients of the other users in the room can then depending on their local timezone work out the math and render the point in time in the timezone of the user.

## Proposal

For events of type `m.room.message` with `msgtype` of `m.text` and `format` `org.matrix.custom.html` in the `content` field, the `formatted_body` field supports containing a `mx-time` element. Here is an example:

```json
{
"type": "m.room.message",
"content": {
"msgtype": "m.text",
"format": "org.matrix.custom.html",
"formatted_body": "Shall we have a quick call at <mx-time timezone=\"-120\">9am</mx-time> tomorrow?"
bwindels marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

The `timezone` attribute contains the local timezone offset in minutes from UTC.

### Possible user interface

Clients could either detect when the user writes something that looks like a timestamp and either automatically wrap it in a `<mx-time>`, or propose to do so. Alternatively, clients could have a time button in the composer formatting options that allows to add a time with a dialog, requiring less sophisticated time pattern detection while typing.

When rendering an `<mx-time>` element, clients could render it in a special way, and allow to interact with it to show the time in the timezone of the sender, or any other timezone.
bwindels marked this conversation as resolved.
Show resolved Hide resolved

## Potential issues

For web clients, Firefox always reports the local timezone to be UTC when resist fingerprinting is on. Web clients would therefore need to at least confirm the detected timezone with the user to ensure it does not get sent with a different timezone than the user is actually and create a whole level of confusion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The equivalent local time may depend on the date that the time is for. For example, your "9am tomorrow" may be a different time for me from your "9am next Monday" if my daylight saving time change happens in between. (Yay, time is fun.)

Copy link
Contributor Author

@bwindels bwindels Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will remove this potential issue then.

Copy link
Contributor Author

@bwindels bwindels Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, thinking about it further, I can see how this would a problem with symbolic timezone names, but here I propose to use timezone offsets, which are assumed to be the offset at the referred date for the sender. Makes me wonder if we should rather use symbolic timezone names though, as it migth be hard to calculate an offset for the future taking into account DST changes, ... like this? OTOH, an offset doesn't require you to have a valid list with timezones, although most standard libraries should help you with that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, you'll have to deal with symbolic timezone names for data entry anyway because many people don't even know/remember the offset of their current timezone; and changing the data in the profile as suggested in another place won't help with "world citizens" who live (ok, lived and will live, given the situation) across three different timezones in a single week (I know a few such people). Second, even with the current zone set in the profile or resolved by the browser, sitting in Singapore at 23:00 local time the sender may plan a day in London the next day, writing "let's meet at 7:00 GMT at the airport" - he doesn't even think of using his current local (or GMT) date for that. I'd probably just leave the case of time-without-date alone.

## Alternatives

HTML already supports a [`<time>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time), but it does not have an attribute to set timezone information. So instead of making an attribute up, I decided to go with a different tag.
bwindels marked this conversation as resolved.
Show resolved Hide resolved

## Security considerations

## Unstable prefix

Is a prefix needed for the tag name? If so, we can use `<org.matrix.msc3160.time>`.