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

Africa/Casablanca offset incorrect #98

Closed
lelelyons opened this issue Feb 6, 2019 · 3 comments
Closed

Africa/Casablanca offset incorrect #98

lelelyons opened this issue Feb 6, 2019 · 3 comments

Comments

@lelelyons
Copy link

@lelelyons lelelyons commented Feb 6, 2019

The offset seems to be incorrect (see below), I believe it should be 3600? Or am I misunderstanding something?

screenshot 2019-02-06 at 14 04 23

@philr
Copy link
Member

@philr philr commented Feb 6, 2019

Your time zone data is probably out of date. Morocco's change to permanent UTC+1 was included in the 2018g release of the IANA Time Zone Database. Further changes were made to include fallbacks for Ramadan in 2018h.

With the latest data, I get the expected result:

tz = TZInfo::Timezone.get('Africa/Casablanca')
# => #<TZInfo::DataTimezone: Africa/Casablanca>
tz.current_period.utc_offset
# => 3600

If you are using ZoneinfoDataSource, check to see if there is an updated tzdata package available for your operating system. Otherwise, you can add tzinfo-data version 1.2018.7 or later to your Gemfile and use RubyDataSource.

@philr
Copy link
Member

@philr philr commented Feb 6, 2019

The 2018h 'main' definition of Africa/Casablanca uses a base offset of UTC+1 throughout the year and observes negative daylight savings during Ramadan. There is a 'rearguard' version of the IANA Time Zone Database that changes this around so that a base offset of UTC+0 is used throughout the year and positive daylight savings is observed at all times other than during Ramadan.

If you are using ZoneinfoDataSource and have up to date zoneinfo files built from the 'rearguard' definitions, then utc_offset will return 0, but utc_total_offset will return 3600 for most of the year.

Note also that utc_offset and utc_total_offset have been renamed base_utc_offset and observed_utc_offset respectively in tzinfo version 2.0.0.

@lelelyons lelelyons closed this Feb 7, 2019
@dennismonsewicz
Copy link

@dennismonsewicz dennismonsewicz commented Dec 9, 2020

I am receiving the following error when looking up the Timezone info for Africa/Casablanca

irb(main):031:0> tz = TZInfo::Timezone.get('Africa/Casablanca')
TZInfo::InvalidTimezoneIdentifier: The first offset indicated by the POSIX-style TZ string did not match the final defined offset in file '/usr/share/zoneinfo/Africa/Casablanca'.

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

Successfully merging a pull request may close this issue.

None yet
3 participants