jamespfennell / transiter

Web service for transit data
https://demo.transiter.dev
MIT License
64 stars 7 forks source link

Investigate and/or improve how Transiter handles time #19

Closed jamespfennell closed 4 years ago

jamespfennell commented 5 years ago

The first problem is that Transiter can't be used by SQL Lite right now because if a timetamp is imported into Transiter it doesn't come out the same in the HTTP API! Also it's not clear what the effect of various timezone transformations we perform are.

This needs to be fixed. Also it looks like we use SQL Alchemy with a custom TIMESTAMP type ... maybe this is the problem.

The Arrow library integrates well with SQL Alchemy and may be worth using.

jamespfennell commented 5 years ago

This should be simple at a high level. We want to:

    • Get a timestamp in the GTFS realtime feed
    • Convert it into an Arrow or datetime object.
    • Persist it in the DB
    • Request the same data from the DB.
    • Convert it back to a timestamp.

The result in (5) should equal (1) in all database systems.

It may be worth thinking though about what happens if we change the timezone. Especially with custom parsers, it's nice if we give transit system developers objects in the transit system's timezone, for easier debugging.

jamespfennell commented 4 years ago

As far as I can tell, time is working correctly in v0.4. The roundtrip described above gives the right answer. Going to close.