I don’t know what you’re trying to achieve here. Time.now > Time.now.beginning_of_day'' is false for one microsecond each day at midnight. You shouldn't really have to check for that, it's pretty much the same as writingif true’’. Numerical methods coming to mind, you
might instead want to check if the difference between Time.now and
Time.now.beginnning_of_day is less than a given time period.
I don’t know what you’re trying to achieve here. Time.now > Time.now.beginning_of_day'' is false for one microsecond each day at midnight. You shouldn't really have to check for that, it's pretty much the same as writingif true’’. Numerical methods coming to mind, you
might instead want to check if the difference between Time.now and
Time.now.beginnning_of_day is less than a given time period.
And that is precisely why you need
now = Time.now
if now.some_value < OtherValue.from(now)
instead of
if Time.now.some_value < OtherValue.from(Time.now)
for all practical purposess. The latter code will seem to work, even
when
you do unit tests; but occasionally it will break and you’ll never
figure
out why, since it always works when you debug.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.