From: Carlos Date: 2004-08-27T23:41:28+09:00 Subject: Re: Code Critique Request [James Edward Gray II , 2004-08-27 15.31 CEST] ... > I do THINK my code handles dates correctly, but I've been wrong before. I do, too, after actually reading the code ;)) (taking into account the "adding seconds" issue). > I solved the above problem by generating a list of days (with Time > objects) we are looking at for the calendar and then checking if an > event could occur on that day. That was easier to get my head around. I think it is a good approach. How about building the list beforehand, instead of on each call of #between? ? You could add a method to see if two events fall on the same day, and since you used the same attribute names, it will work also for Time objects: def same_day? other return (year==0 || other.year==0 || year==other.year) && (month==0 || other.month==0 || month==other.month) && (day==other.day) end Later, you can retrieve the events by using: events.each do |key, value| result = list_of_times.map {|t| value.find_all {|e| e.same_day? t } } next if result.all? {|r| r.empty? } puts key result.each_with_index {|r,i| next if r.empty? print( i<7 ? OFFSET[i] : "(#{i})" ) ...etc... end (not tested) Just another approach... I see that your Events class is more generic with its #between? method. HTH