ice_cube
ice_cube copied to clipboard
occurs_at? not working properly?
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!
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...
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 thanks for the reply!
ruby version 2.4.2p198, macOS 10.13.1, Rails 5.1.4, Ice Cube 0.16.2.
use MASTER, because version 0.16.2 not last version of code
@IgorKhlebnikov interesting notion, @avit is that the recommended route? Should I try this in production?