Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Incorrect offsets for dates beyond 2037. #70
Referencing back to the issue in Rails, rails/rails#30408
Specifically, EDT is not included in list of time periods beyond November 2nd, 2037.
time_zone = TZInfo::Timezone.get('America/Toronto') irb(main):005:0> time_zone.periods_for_local(Time.new(2017, 8, 27, 10, 0, 0)) => [#<TZInfo::TimezonePeriod: #<TZInfo::TimezoneTransitionDefinition: #<TZInfo::TimeOrDateTime: 1489302000>,#<TZInfo::TimezoneOffset: -18000,3600,EDT>>,#<TZInfo::TimezoneTransitionDefinition: #<TZInfo::TimeOrDateTime: 1509861600>,#<TZInfo::TimezoneOffset: -18000,0,EST>>>] irb(main):006:0> time_zone.periods_for_local(Time.new(2047, 8, 27, 10, 0, 0)) => [#<TZInfo::TimezonePeriod: #<TZInfo::TimezoneTransitionDefinition: #<TZInfo::TimeOrDateTime: 2140668000>,#<TZInfo::TimezoneOffset: -18000,0,EST>>,nil>
This is problematic because it causes a discrepancy in behaviour between Postgres and our Rails application, where two different dates would be produced by applying time zone offsets.
I assume that you are using TZInfo with the zoneinfo datasource (reading system zoneinfo files rather than using the tzinfo-data gem). You can the datasource being used with
Each zoneinfo file includes a list of the transitions that occur in a time zone. This list obviously cannot extend infinitely far into the future, so there is a cut-off where the transitions end. A "POSIX-TZ-environment-variable-style string" is also included in the file. This can be used to calculate the times of subsequent transitions. The zic command that generates zoneinfo files currently includes transitions up to around the year 2037.
TZInfo is only able to read the list of transitions from zoneinfo files. It does not evaluate the POSIX-TZ string. When used with the zoneinfo data source, TZInfo will therefore not return any transitions beyond about 2037 (and local times beyond this point will remain at the same offset).
I intend to look at supporting the POSIX-TZ string in a future version of TZInfo.
For the time being though, you might like to consider installing the tzinfo-data gem as a datasource. tzinfo-data is based on the same IANA Time Zone database as the zoneinfo files and includes 50 years of future transitions.
To use tzinfo-data as a datasource, just add
It is also worth noting that making assumptions about local times far in the future can be dangerous. The rules concerning time zone offsets and daylight savings time can and do change.