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

Wrong one hour offset on the day the hour changes for DST #67

Open
pietercolpaert opened this issue Jul 26, 2016 · 1 comment
Open

Wrong one hour offset on the day the hour changes for DST #67

pietercolpaert opened this issue Jul 26, 2016 · 1 comment
Labels

Comments

@pietercolpaert
Copy link
Member

pietercolpaert commented Jul 26, 2016

Problem

The GTFS generator script doesn't take into account extra hour on day the clocks are put backwards and doesn't take into account 1 hour less on day the clocks are put 1 hour forward

How to replicate

Load the GTFS feed in any system and check the departure and arrival times on the days the hour change from winter → summer time and vice versa.

I used gtfs2lc to generate connections from this GTFS file.

Examples

2016-03-27: Summer hour (UTC+2) on the day the clocks were set 1 hour forward

{"@type":"Connection","departureStop":"http://irail.be/stations/NMBS/008811221","arrivalStop":"http://irail.be/stations/NMBS/008811213",
// Forgot to substract 1 hour as clocks were set forward
"departureTime":{"$date":"2016-03-27T22:47:00.000Z"},
// → localtime: 2016-03-28T00:47 ==> should have been 2016-03-27T23:47
"arrivalTime":{"$date":"2016-03-27T22:50:00.000Z"},"gtfs:trip":"http://irail.be/trips/IC19453391","gtfs:route":"http://irail.be/vehicle/IC1945",
"_id":"http://irail.be/connections/8811221/20160328/IC1945"}

For the next day, the hour is generated correctly, as no 1 hour disappeared from the day. However, now the identifiers for this departure conflict (which is a big problem for the iRail code base)

{"@type":"Connection","departureStop":"http://irail.be/stations/NMBS/008811221","arrivalStop":"http://irail.be/stations/NMBS/008811213",
"departureTime":{"$date":"2016-03-28T21:47:00.000Z"},
// → Correct local departureTime: 2016-03-28T23:47
"arrivalTime":{"$date":"2016-03-28T21:50:00.000Z"},"gtfs:trip":"http://irail.be/trips/IC19453391","gtfs:route":"http://irail.be/vehicle/IC1945",
"_id":"http://irail.be/connections/8811221/20160328/IC1945"}

2016-10-30: Winter hour (UTC+1) on the day the clocks were set 1 hour backward

Correct day on the 29th, on which we are still on summer time (UTC+2):

{"@type":"Connection","departureStop":"http://irail.be/stations/NMBS/008811213","arrivalStop":"http://irail.be/stations/NMBS/008811221",
"departureTime":{"$date":"2016-10-29T22:12:00.000Z"},
// → Correct local time: 2016-10-30T00:12:00.000
"arrivalTime":{"$date":"2016-10-29T22:15:00.000Z"},"gtfs:trip":"http://irail.be/trips/IC192249921","gtfs:route":"http://irail.be/vehicle/IC1922",
"_id":"http://irail.be/connections/8811213/20161030/IC1922"}

However, on the 30th of October, we forgot to add an hour, as the day lasted 1 hour longer:

{"@type":"Connection","departureStop":"http://irail.be/stations/NMBS/008811213","arrivalStop":"http://irail.be/stations/NMBS/008811221",
"departureTime":{"$date":"2016-10-30T22:12:00.000Z"},
// → Wrong local time as the day lasted 1 hour longer: 2016-10-30T23:12 ==> should have been 2016-10-31T00:12
"arrivalTime":{"$date":"2016-10-30T22:15:00.000Z"},"gtfs:trip":"http://irail.be/trips/IC192249921","gtfs:route":"http://irail.be/vehicle/IC1922","_id":"http://irail.be/connections/8811213/20161030/IC1922"}

Suggested solution

When crossing 3 am, we should start adding or subtracting an hour to the hour we found. However, for the schedules between 2 and 3 am on the 30th of October, I'm not sure what actually happens on the website of SNCB. To be checked!

@pietercolpaert
Copy link
Member Author

The fix is easier than I thought as no trains appear to drive after 1:45. We can just say: everything after 3am gets 1 hour added on the last Sunday of October.

1 hour should be subtracted on the last Sunday of March of each year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant