Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Time range min and max values #2041

Closed
kritik opened this Issue Nov 20, 2012 · 4 comments

Comments

Projects
None yet
3 participants

kritik commented Nov 20, 2012

MRI:

1.9.3p194 :001 > months=1
 => 1 
1.9.3p194 :002 > time = Time.now.utc - months.months
 => 2012-10-20 13:06:06 UTC 
1.9.3p194 :003 > (time.beginning_of_month..time.end_of_month).min
 => 2012-10-01 00:00:00 UTC

Rubinius

rubinius-2.0.0rc1 :010 > (time.beginning_of_month..time.end_of_month).min
TypeError: can't iterate from Time
        from kernel/common/range.rb:60:in `each'
        from kernel/common/enumerable.rb:292:in `min'
        from kernel/common/range19.rb:27:in `min'
        from (irb):10
        from kernel/common/block_environment.rb:75:in `call_on_instance'
        from kernel/common/eval.rb:75:in `eval'
        from kernel/common/kernel19.rb:42:in `loop'
        from kernel/common/throw_catch19.rb:8:in `catch'
        from kernel/common/throw_catch.rb:10:in `register'
        from kernel/common/throw_catch19.rb:7:in `catch'
        from kernel/common/throw_catch19.rb:8:in `catch'
        from kernel/common/throw_catch.rb:10:in `register'
        from kernel/common/throw_catch19.rb:7:in `catch'
        from /home/vladimir/.rvm/gems/rbx-head/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
        from /home/vladimir/.rvm/gems/rbx-head/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
        from /home/vladimir/.rvm/gems/rbx-head/gems/railties-3.2.8/lib/rails/commands.rb:41:in `__script__'
        from kernel/common/codeloader.rb:212:in `require'
        from kernel/common/kernel.rb:648:in `require'
        from script/rails:6:in `__script__'
        from kernel/delta/codeloader.rb:68:in `load_script'
        from kernel/delta/codeloader.rb:118:in `load_script'
        from kernel/loader.rb:615:in `script'
        from kernel/loader.rb:816:in `main'rubinius-2.0.0rc1 :011 > 
Owner

dbussink commented Nov 20, 2012

Simplification that doesn't depend on ActiveSupport or anything else:

(Time.now..Time.now).min

kritik commented Nov 20, 2012

MRI

billing$ irb
1.9.3p327 :001 > (Time.now..Time.now).min
 => 2012-11-20 15:53:16 +0200

rbx

rbx
rubinius-2.0.0rc1 :001 > (Time.now..Time.now).min
TypeError: can't iterate from Time
        from kernel/common/range.rb:60:in `each'
        from kernel/common/enumerable.rb:292:in `min'
        from kernel/common/range19.rb:27:in `min'
        from (irb):1
        from kernel/common/block_environment.rb:75:in `call_on_instance'
        from kernel/common/eval.rb:75:in `eval'
        from kernel/common/kernel19.rb:42:in `loop'
        from kernel/common/throw_catch19.rb:8:in `catch'
        from kernel/common/throw_catch.rb:10:in `register'
        from kernel/common/throw_catch19.rb:7:in `catch'
        from kernel/common/throw_catch19.rb:8:in `catch'
        from kernel/common/throw_catch.rb:10:in `register'
        from kernel/common/throw_catch19.rb:7:in `catch'
        from kernel/common/codeloader.rb:212:in `require'
        from kernel/common/kernel.rb:648:in `gem_original_require (require)'
        from /home/vladimir/.rvm/rubies/rbx-head/lib/rubygems/custom_require.rb:36:in `require'
        from kernel/loader.rb:681:in `irb'
        from kernel/loader.rb:817:in `main'rubinius-2.0.0rc1 :002 >

And it is in the documentation of Range class http://ruby-doc.org/core-1.9.3/Range.html#method-i-min

Contributor

frodsan commented Nov 20, 2012

I think this is already fixed by 04c2c40:

$ rbx
>> (Time.now..Time.now).min
=> 2012-11-20 15:29:50 -0500

@brixen Is this can be closed?

@dbussink dbussink closed this Nov 20, 2012

kritik commented Nov 21, 2012

yes, it works now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment