diff --git a/lang/en/attendance.php b/lang/en/attendance.php index 57a3977..210f821 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -267,11 +267,12 @@ $string['status'] = 'Status'; $string['statuses'] = 'Statuses'; $string['statusdeleted'] = 'Status deleted'; $string['statusset'] = 'Status set {$a}'; -$string['strftimedm'] = '%d.%m'; -$string['strftimedmy'] = '%d.%m.%Y'; -$string['strftimedmyhm'] = '%d.%m.%Y %H.%M'; // Line added to allow multiple sessions in the same day. -$string['strftimedmyw'] = '%d.%m.%y (%a)'; -$string['strftimehm'] = '%H:%M'; // Line added to allow display of time. +$string['strftimedm'] = '%h %d'; +$string['strftimedmy'] = '%d %h %Y'; +$string['strftimedmyhm'] = '%d %h %Y %I.%M%P'; // Line added to allow multiple sessions in the same day. +$string['strftimedmyw'] = '%a %d %h %Y'; +$string['strftimeh'] = '%l%P'; +$string['strftimehm'] = '%l:%M%P'; $string['strftimeshortdate'] = '%d.%m.%Y'; $string['studentid'] = 'Student ID'; $string['summary'] = 'Summary'; diff --git a/renderer.php b/renderer.php index 315f536..de419b8 100644 --- a/renderer.php +++ b/renderer.php @@ -387,8 +387,8 @@ class mod_attendance_renderer extends plugin_renderer_base { private function construct_take_session_info(attendance_take_data $takedata) { $sess = $takedata->sessioninfo; $date = userdate($sess->sessdate, get_string('strftimedate')); - $starttime = userdate($sess->sessdate, get_string('strftimehm', 'attendance')); - $endtime = userdate($sess->sessdate + $sess->duration, get_string('strftimehm', 'attendance')); + $starttime = attendance_strftimehm($sess->sessdate); + $endtime = attendance_strftimehm($sess->sessdate + $sess->duration); $time = html_writer::tag('nobr', $starttime . ($sess->duration > 0 ? ' - ' . $endtime : '')); $sessinfo = $date.' '.$time; $sessinfo .= html_writer::empty_tag('br'); @@ -485,9 +485,8 @@ class mod_attendance_renderer extends plugin_renderer_base { $options = array(); foreach ($takedata->sessions4copy as $sess) { - $start = userdate($sess->sessdate, get_string('strftimehm', 'attendance')); - $end = $sess->duration ? ' - '.userdate($sess->sessdate + $sess->duration, - get_string('strftimehm', 'attendance')) : ''; + $start = attendance_strftimehm($sess->sessdate); + $end = $sess->duration ? ' - '.attendance_strftimehm($sess->sessdate + $sess->duration) : ''; $options[$sess->id] = $start . $end; } $select = new single_select($takedata->url(array(), array('copyfrom')), 'copyfrom', $options); @@ -1153,7 +1152,7 @@ class mod_attendance_renderer extends plugin_renderer_base { foreach ($reportdata->sessions as $sess) { $sesstext = userdate($sess->sessdate, get_string('strftimedm', 'attendance')); $sesstext .= html_writer::empty_tag('br'); - $sesstext .= userdate($sess->sessdate, '('.get_string('strftimehm', 'attendance').')'); + $sesstext .= attendance_strftimehm($sess->sessdate); $capabilities = array( 'mod/attendance:takeattendances', 'mod/attendance:changeattendances' diff --git a/renderhelpers.php b/renderhelpers.php index bf07176..780fb6b 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -217,9 +217,19 @@ class user_sessions_cells_text_generator extends user_sessions_cells_generator { } } +// Used to print simple time - 1am instead of 1:00am +function attendance_strftimehm($time) { + $mins = userdate($time, '%M'); + if ($mins == '00') { + return userdate($time, get_string('strftimeh', 'attendance')); + } else { + return userdate($time, get_string('strftimehm', 'attendance')); + } +} + function construct_session_time($datetime, $duration) { - $starttime = userdate($datetime, get_string('strftimehm', 'attendance')); - $endtime = userdate($datetime + $duration, get_string('strftimehm', 'attendance')); + $starttime = attendance_strftimehm($datetime); + $endtime = attendance_strftimehm($datetime + $duration); return $starttime . ($duration > 0 ? ' - ' . $endtime : ''); } diff --git a/student_attendance_form.php b/student_attendance_form.php index c8fc1ca..3e445ae 100644 --- a/student_attendance_form.php +++ b/student_attendance_form.php @@ -38,7 +38,7 @@ class mod_attendance_student_attendance_form extends moodleform { // Set a title as the date and time of the session. $sesstiontitle = userdate($attforsession->sessdate, get_string('strftimedate')).' ' - .userdate($attforsession->sessdate, get_string('strftimehm', 'mod_attendance')); + .attendance_strftimehm($attforsession->sessdate); $mform->addElement('header', 'session', $sesstiontitle);