### Eclipse Workspace Patch 1.0
#P moodle
Index: mod/scorm/report.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/report.php,v
retrieving revision 1.46.2.11
diff -u -r1.46.2.11 report.php
--- mod/scorm/report.php	11 Mar 2009 01:18:41 -0000	1.46.2.11
+++ mod/scorm/report.php	21 Mar 2009 13:41:27 -0000
@@ -261,7 +261,7 @@
                                 $row[] = '<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
                                          $strstatus.'" />&nbsp;'.format_string($sco->title);
                                 $row[] = get_string($trackdata->status,'scorm');
-                                $row[] = $trackdata->total_time;
+                                $row[] = scorm_format_date_time($trackdata->total_time);
                                 $row[] = $score;
                                 $row[] = $detailslink;
                             } else {
@@ -300,7 +300,7 @@
             }
             $strstatus = get_string($trackdata->status,'scorm');
             echo '<img src="'.$scormpixdir.'/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
-            $strstatus.'" />&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
+            $strstatus.'" />&nbsp;'.scorm_format_date_time($trackdata->total_time).'<br />'.$scoreview.'<br />';
             echo '</div>'."\n";
             echo '<hr /><h2>'.get_string('details','scorm').'</h2>';
 
@@ -333,7 +333,11 @@
                     $printedelements[]=$element;
                     $row = array();
                     $row[] = get_string($key,'scorm');
-                    $row[] = s($trackdata->$element);
+                    if ($key == 'time') {
+                        $row[] = s(scorm_format_date_time($trackdata->$element));
+                    } else {
+                        $row[] = s($trackdata->$element);
+                    }
                     $table->data[] = $row;
                 }
             }
@@ -442,7 +446,11 @@
                         $existelements = true;
                         $row = array();
                         $row[] = get_string($element,'scorm') != '[['.$element.']]' ? get_string($element,'scorm') : $element;
-                        $row[] = s($value);
+                        if (strpos($element, '_time') === false) {
+                            $row[] = s($value);
+                        } else {
+                            $row[] = s(scorm_format_date_time($value));
+                        }
                         $table->data[] = $row;
                     }
                 }
Index: mod/scorm/locallib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/scorm/locallib.php,v
retrieving revision 1.46.2.31
diff -u -r1.46.2.31 locallib.php
--- mod/scorm/locallib.php	11 Mar 2009 20:25:04 -0000	1.46.2.31
+++ mod/scorm/locallib.php	21 Mar 2009 13:41:27 -0000
@@ -1324,4 +1324,31 @@
     delete_records('scorm_scoes_track', 'userid', $userid, 'scormid', $scormid, 'attempt', $attemptid);
     return true;
 }
+
+/**
+ * Converts SCORM date/time notation to human-readable format
+ * @param $datetime string SCORM date/time
+ * @return string human-readable date/time
+ */
+function scorm_format_date_time($datetime) {
+    if ($datetime[0] != 'P') {
+        return $datetime;
+    }
+    
+    $stryears = get_string('numyears');
+    $strmonths = get_string('nummonths');
+    $strdays = get_string('numdays');
+    $strhours = get_string('numhours');
+    $strminutes = get_string('numminutes');
+    $strseconds = get_string('numseconds'); 
+    
+    $pattern = array( '#([A-Z])0+Y#', '#([A-Z])0+M#', '#([A-Z])0+D#', '#P(|\d+Y)0*(\d+)M#', '#0*(\d+)Y#', '#0*(\d+)D#', '#P#',
+                      '#([A-Z])0+H#', '#([A-Z])[0.]+S#', '#T(|\d+H)0*(\d+)M#', '#0*(\d+)H#', '#0*([\d.]+)S#', '#T#' );
+    $replace = array( '$1', '$1', '$1', '$1$2 '.$strmonths.' ', '$1 '.$stryears.' ', '$1 '.$strdays.' ', '',
+                      '$1', '$1', '$1$2 '.$strminutes.' ', '$1 '.$strhours.' ', '$1 '.$strseconds, '');
+
+    $result = preg_replace($pattern, $replace, $datetime);
+    
+    return $result;
+}
 ?>
\ No newline at end of file
