floraison / et-orbi

Time zones for fugit and rufus-scheduler. Urbi et Orbi.
MIT License
24 stars 11 forks source link

Issue with get_tzone blowing up #1

Closed jstrouse closed 7 years ago

jstrouse commented 7 years ago

I'm using Rails 2.3, rufus-scheduler 3.4, resque-scheduler 4.3, and tzinfo 0.3.53, et-orbi 1.0.3

When I start the scheduler, I'm getting

NoMethodError: undefined method `identifier' for nil:NilClass
.rvm/gems/ruby-2.3.3/gems/tzinfo-0.3.53/lib/tzinfo/timezone.rb:502:in `<=>'
.rvm/gems/ruby-2.3.3/gems/et-orbi-1.0.3/lib/et-orbi.rb:92:in `=='

What I'm finding is that I have a timezone set for the get_tzone function and it doesn't know how to respond to the == nil or the == :local from lines 92 and 93.

In order to make it work, I simply moved the return if you have a timezone above the nil and local check so it now looks like

return o if o.is_a?(::TZInfo::Timezone)
return nil if o == nil
return local_tzone if o == :local
return ::TZInfo::Timezone.get('Zulu') if o == 'Z'
jmettraux commented 7 years ago

tzinfo 0.3.53: https://github.com/tzinfo/tzinfo/blob/015768f4a1656ced80af6183f093e6ba8dd15276/lib/tzinfo/timezone.rb#L501-L503

    def <=>(tz)
      identifier <=> tz.identifier
    end

tzinfo 1.2.3: https://github.com/tzinfo/tzinfo/blob/02bcddd3ee748b4e9556335b3d714c7e1f459c77/lib/tzinfo/timezone.rb#L616-L619

    def <=>(tz)
      return nil unless tz.is_a?(Timezone)
      identifier <=> tz.identifier
    end

An easy fix would be to recommend upgrading TZInfo, but Rails here is a 2.x so that probably pins TZInfo to this older version. Easier to fix that at the et-orbi level.

jmettraux commented 7 years ago

et-orbi 1.0.4, which includes this change, has been released https://rubygems.org/gems/et-orbi/versions/1.0.4

jmettraux commented 7 years ago

Thanks a lot!