bokmann / business_time

Support for doing time math in business hours and days
MIT License
1.27k stars 215 forks source link

Support Time gem version >= 0.2.0 #211

Closed mpg-tomohiko-mimura closed 2 years ago

mpg-tomohiko-mimura commented 2 years ago

https://github.com/ruby/time/commit/6b8cc4799ef8c62efd5b414c3d7580ff3a7ecdec This commit removes Time::RFC2822_DAY_NAME, which causes an error.

This version of the time gem will be included in ruby 3.1.0. (https://github.com/ruby/ruby/commit/e6b3eab1b70434485a4b9e1115bf8454f34cf5c2


time gem version 0.2.0

$ irb
irb(main):001:0>  require 'time'
=> true
irb(main):002:0> Gem.loaded_specs['time'].version
=> Gem::Version.new("0.2.0")
irb(main):003:0> require 'business_time'
=> true
irb(main):004:0> 1.business_hour.from_now
/Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/config.rb:195:in `int_to_wday': uninitialized constant Time::RFC2822_DAY_NAME (NameError)

        ::Time::RFC2822_DAY_NAME.map(&:downcase).map(&:to_sym)[num]
              ^^^^^^^^^^^^^^^^^^
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/config.rb:124:in `beginning_of_workday'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/time_extensions.rb:29:in `beginning_of_workday'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/time_extensions.rb:47:in `before_business_hours?'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/time_extensions.rb:58:in `roll_forward'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/business_hours.rb:42:in `calculate_after'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/business_hours.rb:27:in `after'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/business_time-0.10.0/lib/business_time/business_hours.rb:23:in `from_now'
    from (irb):4:in `<main>'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/lib/ruby/gems/3.1.0/gems/irb-1.3.8.pre.11/exe/irb:11:in `<top (required)>'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/bin/irb:25:in `load'
    from /Users/tomohiko.mimura/.rbenv/versions/3.1.0-preview1/bin/irb:25:in `<main>'

time gem version 0.1.0

$ irb
irb(main):001:0> require 'time'
=> true
irb(main):002:0> Gem.loaded_specs['time'].version
=> Gem::Version.new("0.1.0")
irb(main):003:0> require 'business_time'
=> true
irb(main):004:0> 1.business_hour.from_now
=> 2021-11-15 10:57:08.139192 +0900
rubyFeedback commented 2 years ago

That tripped me up as well - the removal of the constant broke some of my gems.

I don't mind to change my own code, but there isn't a lot of communication from ruby core downstream happening, so the issue tracker here actually helped me a LOT.