|
| 1 | +# MSC4175: Profile field for user time zone |
| 2 | + |
| 3 | +Knowing another user's time zone is useful for knowing whether they are likely |
| 4 | +to respond or not. Example uses include: |
| 5 | + |
| 6 | +* Showing a user's time zone or time zone offset directly. |
| 7 | +* Showing a user's local time (with hints of whether it is day or night there). |
| 8 | + |
| 9 | + |
| 10 | +## Proposal |
| 11 | + |
| 12 | +Profiles can provide an optional `m.tz` field with values equal to names from the |
| 13 | +[IANA Time Zone Database](https://www.iana.org/time-zones). |
| 14 | +Clients can set and fetch this via the [normal API endpoints](https://spec.matrix.org/v1.14/client-server-api/#profiles). |
| 15 | + |
| 16 | +* Servers MAY validate that the value is a valid IANA time zone. If deemed invalid |
| 17 | + they MUST return a 400 error with error code `M_INVALID_PARAM`. |
| 18 | +* Clients MUST handle invalid or unknown values. One approach may be processing the value as though it was never set. |
| 19 | + |
| 20 | +The rationale for somewhat loose validation is that different clients/servers may have |
| 21 | +different understanding of valid time zones, e.g. different versions of the time zone |
| 22 | +database. |
| 23 | + |
| 24 | +If the field is not provided, it SHOULD be interpreted as having no time zone information |
| 25 | +for that user. |
| 26 | + |
| 27 | +An example request to set the time zone would be: |
| 28 | + |
| 29 | +``` |
| 30 | +PUT /_matrix/client/v3/profile/@alice:example.org/m.tz |
| 31 | +
|
| 32 | +{ |
| 33 | + "m.tz": "America/New_York" |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +Similarly when retrieving a user's profile: |
| 38 | + |
| 39 | +``` |
| 40 | +GET /_matrix/client/v3/profile/@alice:example.org |
| 41 | +
|
| 42 | +{ |
| 43 | + "displayname": "Alice", |
| 44 | + "m.tz": "Europe/Paris" |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | + |
| 49 | +## Potential issues |
| 50 | + |
| 51 | +Clients may need to understand IANA time zone names to show useful information to users. |
| 52 | +Some languages make this easy, e.g. JavaScript can handle this using |
| 53 | +[`Date.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString). |
| 54 | +This may cause clients to bundle the IANA time zone database (and thus also keep it |
| 55 | +up to date). |
| 56 | + |
| 57 | +Using the IANA time zone name has the downside that it does now allow arbitrary offsets, |
| 58 | +which may be required for time zones which are not internationally recognized. |
| 59 | + |
| 60 | +Clients will need to manually update the profile field when the user changes time zone. |
| 61 | +This could be automated by clients based on location, or left as a manual change to |
| 62 | +users. |
| 63 | + |
| 64 | +Clients may wish to periodically fetch the time zone of other users as it is |
| 65 | +liable to change somewhat frequently. Currently, profile data isn't propagated/synchronized |
| 66 | +between servers, but that's left to a future MSC to solve. It is recommended that |
| 67 | +clients cache the value for 12 - 24 hours. |
| 68 | + |
| 69 | +There should not be backwards compatibility concerns since clients should be ignoring |
| 70 | +unknown profile fields. |
| 71 | + |
| 72 | + |
| 73 | +## Alternatives |
| 74 | + |
| 75 | +The time zone offset could be included directly (in minutes/seconds or in `[+-]HH:MM` form). |
| 76 | +This would require clients to manually update the profile field during daylight |
| 77 | +savings. Using the IANA time zone name is robust against this. |
| 78 | + |
| 79 | + |
| 80 | +### Delegate profile fields |
| 81 | + |
| 82 | +There are several standards related to storing of contact information electronically, |
| 83 | +notably vCard and its derivatives (see below). It is unclear if Matrix profile |
| 84 | +information is similar enough to the contact information found in vCard to warrant using |
| 85 | +that format directly, although there is certainly some overlap. |
| 86 | + |
| 87 | +Some of the JSON formats for vCard which include time zone information are detailed below: |
| 88 | + |
| 89 | +[RFC7095: jCard The JSON Format for vCard](https://datatracker.ietf.org/doc/html/rfc7095) |
| 90 | +format could be used instead, but this doesn't make much sense unless the entire |
| 91 | +profile was replaced. |
| 92 | + |
| 93 | +[RFC9553](https://datatracker.ietf.org/doc/html/rfc9553) offers an alternative |
| 94 | +representation for contacts (which is not backwards compatible with vCard). There |
| 95 | +exists `timeZone` field under the `addresses` field which uses an time zone name |
| 96 | +from the IANA Time Zone Database. |
| 97 | + |
| 98 | +Note there's an alternative [jCard](https://microformats.org/wiki/jCard) format |
| 99 | +which is a non-standard derivative of [hCard](https://microformats.org/wiki/hcard). |
| 100 | + |
| 101 | + |
| 102 | +### Competitive analysis |
| 103 | + |
| 104 | +Slack's [`users.info` API call](https://api.slack.com/methods/users.info) includes |
| 105 | +3 separate fields: |
| 106 | + |
| 107 | +* `tz`: the time zone database name (e.g. `"America/New_York"`) |
| 108 | +* `tz_label`: a friendly name (e.g. `"Eastern Daylight Time"`) |
| 109 | +* `tz_offset`: offset in seconds as an integer (e.g. `-14400`) |
| 110 | + |
| 111 | +XMPP uses either: |
| 112 | + |
| 113 | +* [XEP-054](https://xmpp.org/extensions/xep-0054.html) uses vCard |
| 114 | + ([RFC2426](https://datatracker.ietf.org/doc/html/rfc2426)) converted to XML via |
| 115 | + [draft-dawson-vcard-xml-dtd-01](https://datatracker.ietf.org/doc/html/draft-dawson-vcard-xml-dtd-01) |
| 116 | +* [XEP-0292](https://xmpp.org/extensions/xep-0292.html) uses xCard: vCard XML Representation |
| 117 | + ([RFC6351](https://datatracker.ietf.org/doc/html/rfc6351)), see also vCard4 |
| 118 | + ([RFC6351](https://datatracker.ietf.org/doc/html/rfc6351)) |
| 119 | + |
| 120 | +Rocket.Chat provides a user's [time zone offset](https://developer.rocket.chat/docs/user) |
| 121 | +in the `utcOffset` field. |
| 122 | + |
| 123 | +Mattermost [returns an object](https://api.mattermost.com/#tag/users/operation/GetUser) |
| 124 | +with the user's manual and/or automatic IANA time zone name. |
| 125 | + |
| 126 | +Discord, Twitter, and IRC don't provide a user's time zone. |
| 127 | + |
| 128 | + |
| 129 | +## Security considerations |
| 130 | + |
| 131 | +Showing a user's time zone gives some information to their location. There is currently |
| 132 | +no way to limit what profile fields other users can see. |
| 133 | + |
| 134 | +Clients may wish to warn users when providing a time zone and give |
| 135 | +the option to not include it in their profile. |
| 136 | + |
| 137 | + |
| 138 | +## Unstable prefix |
| 139 | + |
| 140 | +`us.cloke.msc4175.tz` should be used in place of `m.tz`. |
| 141 | + |
| 142 | +Clients may immediately use the stable profile field once this MSC is accepted. This is |
| 143 | +a client-to-client protocol and no feature negotiation is necessary. |
| 144 | + |
| 145 | + |
| 146 | +## Dependencies |
| 147 | + |
| 148 | +Requires [MSC4133](https://github.com/matrix-org/matrix-spec-proposals/pull/4133). |
0 commit comments