Hi, I can't seem to figure out how to do math with military time.
function AddTime(%time1,%time2)
{
%time1 = strReplace(%time1,":","");
%time2 = strReplace(%time2,":","");
%t1m = strLen(%time1) > 3 ? getSubStr(%time1,2,2) : getSubStr(%time1,1,2);
%t2m = strLen(%time2) > 3 ? getSubStr(%time2,2,2) : getSubStr(%time2,1,2);
%t1h = strLen(%time1) > 3 ? getSubStr(%time1,0,2) : getSubStr(%time1,0,1);
%t2h = strlen(%time2) > 3 ? getSubStr(%time2,0,2) : getSubStr(%time2,0,1);
if(%t1m + %t2m > 60)
{
%tm = (%t1m + %t2m) % 60;
%ah = mFloor((%t1m + %t2m) / 60);
}
else
{
%tm = %t1m + %t2m;
}
if(%t1h + %t2h > 23)
{
%th = ((%t1h + %t2h) % 23) + %ah;
}
else
{
%th = (%t1h + %t2h) + %ah;
}
if(%tm == 60)
{
%tm = "00";
%th++;
}
if(strLen(%tm) == 1)
%tm = "0" @ %tm;
if(strLen(%th) == 1)
%th = "0" @ %th;
if(%th @ %tm > 2400)
{
%time = %th @ %tm + (%th @ %tm) % 2400;
}
else
{
%time = %th @ %tm;
}
return %time;
}
This is my code for adding two times. It's not perfect, it doesn't work completely, it can probably be simplified or rewritten, but this is what I've got going on right now. Does anyone have a better way to handle this?