Normally, it's easy to use th limit: tag in Liquid to restrict the outputs of a post loop. The following code, for example, will simply list the 5 events with the most recent date.
{% for event in site.categories.events limit:5 %}
<h2>{{ event.title }}</h2>
{% endfor %}But things get tricky if we want to show the first five events in the past. To show past events, we compare the current time with the time of the event, and tell our loop only to output those events where (EventDate < CurrentDate). That's not too difficult, and can be done by translating the dates as the number of seconds that have passed since computers started wearing watches. Here's an example: