diff --git a/calendar/event_form.php b/calendar/event_form.php
index 1dd18d1..23c7e62 100644
--- a/calendar/event_form.php
+++ b/calendar/event_form.php
@@ -128,10 +128,23 @@ class event_form extends moodleform {
         if ($newevent) {
 
             $mform->addElement('checkbox', 'repeat', get_string('repeatevent', 'calendar'), null, 'repeat');
-            $mform->addElement('text', 'repeats', get_string('repeatweeksl', 'calendar'), 'maxlength="10" size="10"');
+            $mform->addElement('text', 'repeats', get_string('repeat_frequency', 'calendar'), 'maxlength="5" size="5"');
+            $repeat_days_array = array();
+            $repeat_days_array[0] = get_string('sunday', 'calendar');
+            $repeat_days_array[1] = get_string('monday', 'calendar');
+            $repeat_days_array[2] = get_string('tuesday', 'calendar');
+            $repeat_days_array[3] = get_string('wednesday', 'calendar');
+            $repeat_days_array[4] = get_string('thursday', 'calendar');
+            $repeat_days_array[5] = get_string('friday', 'calendar');
+            $repeat_days_array[6] = get_string('saturday', 'calendar');
+            $select = &$mform->addElement('select','repeat_day', get_string('repeat_day', 'calendar'), $repeat_days_array, array());
+            $select->setMultiple(true);
+            $mform->addElement('date_selector', 'repeat_end', get_string('repeat_end','calendar'));
             $mform->setType('repeats', PARAM_INT);
             $mform->setDefault('repeats', 1);
             $mform->disabledIf('repeats','repeat','notchecked');
+            $mform->disabledIf('repeat_day','repeat','notchecked');
+            $mform->disabledIf('repeat_end','repeat','notchecked');
 
         } else if ($repeatedevents > 0) {
 
@@ -176,6 +189,10 @@ class event_form extends moodleform {
             $errors['timedurationminutes'] = get_string('invalidtimedurationminutes', 'calendar');
         }
 
+        if ($data['repeat_end'] < $data['timestart']) {
+            $errors['repeat_end'] = get_string('invalidtimerepeatend', 'calendar');
+        }
+
         return $errors;
     }
 
diff --git a/calendar/lib.php b/calendar/lib.php
index 4917100..e7f9c4d 100644
--- a/calendar/lib.php
+++ b/calendar/lib.php
@@ -2033,26 +2033,50 @@ class calendar_event {
 
                 $eventcopy = clone($this->properties);
                 unset($eventcopy->id);
-
-                for($i = 1; $i < $eventcopy->repeats; $i++) {
-
-                    $eventcopy->timestart = ($eventcopy->timestart+WEEKSECS) + dst_offset_on($eventcopy->timestart) - dst_offset_on($eventcopy->timestart+WEEKSECS);
-
-                    // Get the event id for the log record.
-                    $eventcopyid = $DB->insert_record('event', $eventcopy);
-
-                    // If the context has been set delete all associated files
-                    if ($usingeditor) {
-                        $fs = get_file_storage();
-                        $files = $fs->get_area_files($this->editorcontext->id, 'calendar', 'event_description', $this->properties->id);
-                        foreach ($files as $file) {
-                            $fs->create_file_from_storedfile(array('itemid'=>$eventcopyid), $file);
+                
+                // Get original starting time of event offset from date
+                $original_start_time = getdate($eventcopy->timestart);
+                $original_time_offset = $original_start_time["seconds"] + ($original_start_time["minutes"] * MINSECS) + ($original_start_time["hours"] * HOURSECS);
+                
+                // Set timer to beginning of the week
+                $advanced_time = strtotime("last sunday", $eventcopy->timestart);
+                
+                while ($advanced_time <= ($eventcopy->repeat_end)) {
+                    // Find the selected days in the week
+                    foreach($eventcopy->repeat_day as $key => $day) { 
+                        $temp_advanced_time = $advanced_time + (($day - date("w", $advanced_time)) * DAYSECS) + $original_time_offset;
+                        $eventcopy->timestart = $temp_advanced_time + dst_offset_on($eventcopy->timestart) - dst_offset_on($temp_advanced_time);
+                               
+                        // Skip if in the past
+                        if($eventcopy->timestart < $this->properties->timestart) {
+                            continue;
+                        }
+                        
+                        // Skip if in the future
+                        if($eventcopy->timestart > $eventcopy->repeat_end) {
+                            continue;
+                        }
+                               
+                        // Do not duplicate the event
+                        if($eventcopy->timestart != $this->properties->timestart) {
+                            $eventcopyid = $DB->insert_record('event', $eventcopy);
+                            $repeatedids[] = $eventcopyid;
+                                   
+                            // If the context has been set delete all associated files
+                            if ($usingeditor) {
+                                $fs = get_file_storage();
+                                $files = $fs->get_area_files($this->editorcontext->id, 'calendar', 'event_description', $this->properties->id);
+                                foreach ($files as $file) {
+                                    $fs->create_file_from_storedfile(array('itemid'=>$eventcopyid), $file);
+                                }
+                            }
+                                   
+                            // Log the event entry.
+                            add_to_log($eventcopy->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventcopyid, $eventcopy->name);
                         }
                     }
-
-                    $repeatedids[] = $eventcopyid;
-                    // Log the event entry.
-                    add_to_log($eventcopy->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventcopyid, $eventcopy->name);
+                    // Move to the next week
+                    $advanced_time += (WEEKSECS * $this->properties->repeats);
                 }
             }
 
diff --git a/lang/en/calendar.php b/lang/en/calendar.php
index b9bcdf0..106cc86 100644
--- a/lang/en/calendar.php
+++ b/lang/en/calendar.php
@@ -88,6 +88,7 @@ $string['hidden'] = 'hidden';
 $string['ical'] = 'iCal';
 $string['invalidtimedurationminutes'] = 'The duration in minutes you have entered is invalid. Please enter the duration in minutes greater than 0 or select no duration.';
 $string['invalidtimedurationuntil'] = 'The date and time you selected for duration until is before the start time of the event. Please correct this before proceeding.';
+$string['invalidtimerepeatend'] = 'The date and time you selected for the end of the repetition is before the start time of the event. Please correct this before proceeding.';
 $string['iwanttoexport'] = 'Export';
 $string['manyevents'] = '{$a} events';
 $string['mon'] = 'Mon';
@@ -117,8 +118,9 @@ $string['repeateditall'] = 'Apply changes to all {$a} events in this repeat seri
 $string['repeateditthis'] = 'Apply changes to this event only';
 $string['repeatevent'] = 'Repeat this event';
 $string['repeatnone'] = 'No repeats';
-$string['repeatweeksl'] = 'Repeat weekly, creating altogether';
-$string['repeatweeksr'] = 'events';
+$string['repeat_day'] = 'Repeat on these days';
+$string['repeat_end'] = 'Repeat until';
+$string['repeat_frequency'] = 'Repeat every <i>x</i> week(s)';
 $string['sat'] = 'Sat';
 $string['saturday'] = 'Saturday';
 $string['shown'] = 'shown';
