openactive / modelling-opportunity-data

OpenActive Modelling Opportunity Data specification
https://www.openactive.io/modelling-opportunity-data/
Other
6 stars 6 forks source link

Proposal: scheduleTimezone #197

Open nickevansuk opened 6 years ago

nickevansuk commented 6 years ago

Proposer

ODI

Use Case

The startTime and endTime of the schedule are currently underspecified, but in practice we recommend they are rendered into the feed in the local time of the associated location (rather than UTC).

This requires the data user to look up the timezone based on the geo lat/lng of the location (which is optional, and the Event may only include a free-text address field at a minimum), in order to resolve the time. As an aside: resolving time from location is not always possible depending on the geography (e.g. the West Bank has two timezones in the same location), so this is inherently flawed.

Further related issues:

As explained here timezones are difficult to calculate, so we should steer away from anything that requires embedding of the specific rules of a timezone. iCal does this using TZID.

Proposal

The Schedule should include a new required property named timeZone, to mirror the iCal TZID (and this should be recommended for inclusion in the schema.org pending implementation too).

The property should be constrained to the values of TZ from the time zone database (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

This also means that it will be natively supported by libraries such as moment.js.

Additionally from this discussion we should mandate that DateTime properties such as startDate and endDate MUST include timezone designator and SHOULD default to the local timezone of the Event (as per unresolved item in https://github.com/openactive/modelling-opportunity-data/issues/78).

Validator rules

Example

        "eventSchedule": [
          {
            "type": "PartialSchedule",
            "repeatFrequency": "P1W",
            "startTime": "20:15",
            "endTime": "20:45",
            "timeZone": "Europe/London",
            "byDay": [
              "http://schema.org/Tuesday"
            ]
          }
        ],

Beta property

(Class) Property Expected Type Description
(pending:Schedule)
beta:timeZone
schema:Text The time zone used to generate occurrences, same as iCal TZID. E.g. 'Europe/London'.
nickevansuk commented 6 years ago

An simpler alternative is that we always assume that the startTime and endTimeare in "floating time" (https://tools.ietf.org/html/rfc5545#section-3.3.5), and that they should just be rendered as-is to the user (6pm is always considered 6pm regardless of the user's timezone).

However, this makes it difficult to generate subEvents from a schedule, as startDate and endDate properties in the subEvents require a timezone (mentioned in https://github.com/openactive/modelling-opportunity-data/issues/78, but not yet included in the spec).

If the schedule is specified in floating time, the subEvents will also need to be generated in floating time (assuming no location-based time zone inference is applied).

Which then leads us to question using timezones at all - should all dates always just be specified in floating time based on the local time of the provider? This would remove the complexity of timezones, but this would create limitations around compatibility with Google Calendar and other systems that use incremental time.

It is not possible to accurately translate between floating and incremental time without making assumptions about location etc, though it looks like Google accepts both: https://developers.google.com/search/docs/data-types/event

Further reading:

nickevansuk commented 6 years ago

Following a reference implementation of this, I have observed the following:

nickevansuk commented 5 years ago

Proposed way forward

Add timeZone as per original proposal, as floating time is much less useful and requires more radical changes across all existing implementers

nickevansuk commented 4 years ago

Noting this has now been added to schema.org as schema:scheduleTimezone, however this still needs to be added as a REQUIRED property to Schedule and PartialSchedule in the modelling specification.

nickevansuk commented 3 years ago

Note an outstanding specification change based on the above, which is required for booking:

In order to make the data more useful, I recommend that the "always specify date/times in UTC" recommendation be revised to "always specify date/times with the timezone designator set to the local timezone of the Event".

See also https://github.com/openactive/realtime-paged-data-exchange/issues/88