วันเสาร์ที่ 28 กรกฎาคม พ.ศ. 2555

HourUse (no bug)

real HourUse(real rFromTime, real rToTime)
{
    real rTimeFrom, rTimeTo, rTimeRa, rTimeRb, rTimeRc, rTimeR;
    int  iTimea, iTimeb;
    real rTimeMinute;
    int  turn2minute;
    ;

    rTimeFrom  =  rFromTime;
    rTimeTo =  rToTime;

    if( rTimeFrom == rTimeTo)
    {
      rTimeR = 0;
    }
   
    else if(rTimeTo > rTimeFrom)
    {
      rTimeR =  (rTimeTo-  rTimeFrom)/3600;

      if((rTimeTo - rTimeFrom) mod 3600 != 0)
      {
        rTimeMinute = (((rTimeTo - rTimeFrom) mod 3600)/60)*0.01; // minute
        turn2minute = rTimeR; // hour (cut minute by interger variable)
      }
      rTimeR = turn2minute + rTimeMinute; // hour.minute
    }
    else if(rTimeTo < rTimeFrom)
    {
      rTimeR = 12 + (rTimeTo + 43200 - rTimeFrom)/3600;
      if((rTimeTo - rTimeFrom) mod 3600 != 0)
      {
        rTimeMinute = 0.60 + (((rTimeTo - rTimeFrom) mod 3600)/60)*0.01; // minute
        turn2minute = rTimeR; // hour (cut minute by interger variable)
        rTimeR = turn2minute + rTimeMinute; // hour.minute
      }
    }
   // info(strfmt("%1 - %2 = %3 = %4 Hrs %5 Minute",rTimeTo,rTimeFrom,(rTimeTo - rTimeFrom),rTimeR,rTimeMinute));
    return rTimeR;
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น