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
TZInfo with ActiveSupport - Samoa Timezone error #66
I am having the same issue as this user, that created this issue in repository of Rails: (rails/rails#27419)
Steps to reproduce
In rails console.
Rails version: 5.0.2
Ruby version: 2.3.3
It looks like there is a bug with the TZInfo zoneinfo data source that is causing the Pacific/Apia time zone (that Active Support calls Samoa) to be represented with a base offset of -11 hours and a daylight savings offset of either +24 or +25 hours (instead of a base offset of +13 hours and a daylight savings offset of either 0 or +1 hour):
require 'tzinfo' TZInfo::DataSource.set(:zoneinfo) period = TZInfo::Timezone.get('Pacific/Apia').period_for_utc(Time.utc(2017, 3, 6)) period.utc_offset / 3600 # => -11 period.std_offset / 3600 # => 25 period.utc_total_offset / 3600 # => 14
The reason for the difference between
The expected behaviour is that
Pacific/Apia switched from one side of the International Date Line to the other in December 2011. I suspect that the code that attempts to derive the daylight savings offset from zoneinfo files is not handling this change correctly.
I'll look into fixing the bug. In the mean time, you can work around the problem by using the
require 'tzinfo' TZInfo::DataSource.set(:ruby) period = TZInfo::Timezone.get('Pacific/Apia').period_for_utc(Time.utc(2017, 3, 6)) period.utc_offset / 3600 # => 13 period.std_offset / 3600 # => 1 period.utc_total_offset / 3600 # => 14
To change the data source, you'll need to add a dependency on