ice_cube icon indicating copy to clipboard operation
ice_cube copied to clipboard

occurs_at? not working properly?

Open abyx opened this issue 7 years ago • 5 comments

Thanks for this awesome lib!

I think there's something I'm misunderstanding here, as occurs_at? seems to return false for the objects I just got from the schedule itself, e.g.:

s = IceCube::Schedule.new(Time.now.change(sec: 0)) do |s|
  s.add_recurrence_rule(IceCube::Rule.weekly.day(:monday).hour_of_day(8))
end
s.occurs_at? s.first # => false
s.occurs_at? s.first.to_time # => false

What's the intended way of checking that a Time object marks the beginning of a recurrence with a duration? Thanks!

abyx avatar Nov 12 '17 21:11 abyx

After seeing it mentioned in some other issues here during some digging, I saw a mention of zeroing usec as well, so I added usec: 0 to the change call above, still got the same results.

Then, I added a timezone: Time.now.change(sec: 0, usec: 0).in_time_zone('America/New_York'). For some reason that solves the issue, but I'm not sure this is the wanted behaviour...

abyx avatar Nov 16 '17 08:11 abyx

I'm not able to reproduce your first example. Can you give a little more context? (versions etc.)

require 'active_support/time'
#=> true

s = IceCube::Schedule.new(Time.now.change(sec: 0)) do |s|
  s.add_recurrence_rule(IceCube::Rule.weekly.day(:monday).hour_of_day(8))
end
#=> #<IceCube::Schedule:...>

s.occurs_at? s.first # => false
#=> true

s.occurs_at? s.first.to_time # => false
#=> true

avit avatar Nov 18 '17 16:11 avit

@avit thanks for the reply!

ruby version 2.4.2p198, macOS 10.13.1, Rails 5.1.4, Ice Cube 0.16.2.

abyx avatar Nov 23 '17 07:11 abyx

use MASTER, because version 0.16.2 not last version of code

IgorKhlebnikoff avatar Feb 20 '18 20:02 IgorKhlebnikoff

@IgorKhlebnikov interesting notion, @avit is that the recommended route? Should I try this in production?

abyx avatar Feb 21 '18 06:02 abyx