-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
1.9
-
None
-
MOODLE_19_STABLE
in scorm_13.js.php
AddTime("PT39M15S","PT39M15S") returns PT7H18M30S the correct value is PT1H18M30S.
this is my correction:
function AddTime (first, second) {
var timestring = 'P';
var matchexpr = /^P((\d+)Y)?((\d+)M)?((\d+)D)?(T((\d+)H)?((\d+)M)?((\d+(\.\d
)?)S)?)?$/;
var firstarray = first.match(matchexpr);
var secondarray = second.match(matchexpr);
if ((firstarray != null) && (secondarray != null)) {
var firstsecs=0;
if(parseFloat(firstarray[13],10)>0)
var secondsecs=0;
if(parseFloat(secondarray[13],10)>0)
var secs = firstsecs+secondsecs; //Seconds
var change = Math.floor(secs/60);
secs = Math.round((secs-(change*60))*100)/100;
var firstmins=0;
if(parseInt(firstarray[11],10)>0)
var secondmins=0;
if(parseInt(secondarray[11],10)>0)
var mins = firstmins+secondmins+change; //Minutes
change = Math.floor(mins / 60);
mins = Math.round(mins-(change*60));
var firsthours=0;
if(parseInt(firstarray[9],10)>0)
var secondhours=0;
if(parseInt(secondarray[9],10)>0)
var hours = firsthours+secondhours+change; //Hours
change = Math.floor(hours/24);
hours = Math.round(hours-(change*24));
var firstdays=0;
if(parseInt(firstarray[6],10)>0)
var seconddays=0;
if(parseInt(secondarray[6],10)>0)
var days = Math.round(firstdays+seconddays+change); // Days
var firstmonths=0;
if(parseInt(firstarray[4],10)>0)
var secondmonths=0;
if(parseInt(secondarray[4],10)>0)
var months = Math.round(firstmonths+secondmonths);
var firstyears=0;
if(parseInt(firstarray[2],10)>0)
var secondyears=0;
if(parseInt(secondarray[2],10)>0)
var years = Math.round(firstyears+secondyears);
}
if (years > 0)
if (months > 0)
{ timestring += months + 'M'; }if (days > 0)
{ timestring += days + 'D'; } if ((hours > 0) || (mins > 0) || (secs > 0)) {
timestring += 'T';
if (hours > 0)
if (mins > 0)
{ timestring += mins + 'M'; }if (secs > 0)
{ timestring += secs + 'S'; } }
return timestring;
}