gtfs-validator
gtfs-validator copied to clipboard
Timezone mishandling can lead to errors
Describe the bug
It seems that the timezone used by the validator code is the one where the validator is running.
This is wrong since the validator could be running anywhere in the world, in a time zone different from the agency time zone. This is particularly true for the web validator that is running somewhere on the cloud.
The problem is that the now at two locations can be on different days. This potentially breaks validators like FeedExpirationDateValidator
that give FeedExpirationDate7DaysNotice
and FeedExpirationDate30DaysNotice
As an example it could be the 9th of January in Bangkok, and the 8th in Montreal. Let's say the agency time zone is the one for Bangkok (ICT I think). And let's say the feed end date is the 16th of January. We would expect to have the FeedExpirationDate7DaysNotice since 9 + 7 = 16. But since the Montreal time zone is used by the validator, it will not issue the notice until the next day (8 + 7 = 15)
We should change the validator to use the agency time zone, not the local time zone where the validator is running.
It's kind of a corner case where the error would not be very consequential (missing the notice by one day). But it should still be corrected. Plus there might be other notices affected.
Steps/Code to Reproduce
See the example above. Ideally we should have a test case for that. To be written.
Expected Results
See the example above
Actual Results
See example above
Screenshots
No response
Files used
No response
Validator version
4.20
Operating system
irrelevant
Java version
No response
Additional notes
No response
As commented in #1636, it's straightforward to supply a timezone (ZoneId) to the function now() that gets the date to use for processing. (Both with the existing code and after PR #1636.)
Since timezone is a required field in the feed, I think the only coding challenges will be reading the agency file before setting this time and identifying invalid timezones. The only design question I see is what to do when the timezone is invalid. Fall back to the system timezone?