dbopendata / db-fahrplan-api

DB Fahrplan API
31 stars 1 forks source link

Provide dates/times in local time zone as well as UTC #2

Open highsource opened 8 years ago

highsource commented 8 years ago

The response contains date and time of arrivals or departures without the time zone:

{
    name: "ICE 577",
    type: "ICE",
    stopid: "8000105",
    stop: "Frankfurt(Main)Hbf",
    time: "15:00",
    date: "2016-02-22",
    origin: "Hamburg-Altona",
    track: "6",
    JourneyDetailRef: {
        ref: "http://open-api.bahn.de/bin/rest.exe/v1.0/journeyDetail?ref=360258%2F123395%2F442424%2F101126%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8000105%26station_type%3Darr%26authKey%3Dcnklsdfhbgukdvd%26lang%3Dde%26format%3Djson%26"
    }
}

These are local dates and times, time zone information is not known. This makes it impossible to do large-scale routing since times and dates can't be matched without time zone info. Timezone info can be theoretically deducted from the geo location of the station, but that's indirect, complex, requires additional data and not guaranteed to give correct results.

Zitat:

Es gibt allerdings ... noch ein paar Probleme, z.B. die fehlende Zeitzonen-Information. Alle Abfahrten und Ankünfte sind in der Ortszeit des jeweiligen Bahnhofs. Die einzigen Informationen, die auf die Zeitzone schließen lassen, sind die Geokoordinaten der Bahnhöfe. Dadurch ist es nicht möglich, Abfahrts- und Ankunftszeiten eindeutig zu bestimmen: zwar enthält die API momentan nur Fernverkehrszüge, die durch Deutschland fahren, das ist aber schon genug, um Verwirrung zu stiften. Der EuroNight 23 fährt von Moskau nach Strasbourg und verlässt Moskau um 19:15 UTC. Die API verrät nur, dass er um 22:15 Ortszeit abfährt, sagt aber nicht, in welcher Zeitzone.

Am besten ließe sich das Problem lösen, indem alle Zeiten als UTC zurückgegeben werden und zusätzlich für Darstellungszwecke die Zeitzone (oder zumindest die Differenz zu UTC) angegeben wird.

The solution is to provide dates/times in local time zone as well as in UTC:

    dateTimeUTC: "2016-02-22T15:00:00Z",
    dateTimeLocal: "2016-02-22T15:00:00"

This is, by the way, how Lufthansa does it for flight schedules.