diff --git a/calendar/lib.php b/calendar/lib.php
index 78de07a3155..4cc0e72c87a 100644
--- a/calendar/lib.php
+++ b/calendar/lib.php
@@ -1741,10 +1741,11 @@ function calendar_format_event_time($event, $now, $linkparams = null, $usecommon
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = $timestart . ' » ' . html_writer::link($url, $dayend) . $timeend;
} else {
- $url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
+ // The event is in the future, print start and end links.
+ $url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $starttime);
$eventtime = html_writer::link($url, $daystart) . $timestart . ' » ';
- $url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $starttime);
+ $url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime .= html_writer::link($url, $dayend) . $timeend;
}
}