$EventList, used to sort events for use with FOREACH EVENTLIST loop, is not initialized in getEvents() (unlike $Grid). The effect of that is that if the template calls getEvents() more than once with different values for range, the loop will return the events matching the largest range previously specified. Clear as mud? How about an example...
I have a "combo" template, where I always show a small month calendar using getEvents({range=>'month'}) and FOREACH GRID ROW/FOREACH GRID COLUMN loops. On the right (main area) I show the list of events that can be specified for a selected day, week, or month; this is achieved using getEvents( ... ) and FOREACH EVENTLIST/FOREACH EVENT loops, and the range is passed as a CGI parameter. The list on the right would always show the events for the entire month, regardless of selected range, because $EventList would be filled out at the first pass through getEvents(), when the entire month is retrieved (so that the small grid can be displayed), and subsequent passes simply overwrite the same info for a subset of existing entries; the remaining, irrelevant entries remain in the hash.
I fixed that by adding
my ($EventList);
in calendar.pl, right after
my ($Grid)
(line 640 in version 3.21).