Table of Content
HAL Forum
function val HoursDiff (
date FrDate,time FrTime,date ToDate,time ToTime)
Description:
Returns the time difference between two date and times in hours
Parameters:
FrDate Start date
FrTime Start time
ToDate End date
ToTime End time
global
function val NumberOfStayDays(Date SDate,Date EDate,Time STime,Time ETime,Integer invby)
begin
  record HotelBlock HBr;
  val Quantity,tmp;

  Blockload(HBr);
  if (invby==0) then begin  // hours
    Quantity = HoursDiff(SDate,STime,EDate,ETime);
  end;
  If (invby==1) then begin   // days
    Quantity = DateDiff(EDate,SDate);
    if (Quantity==0) then begin
      vTimeDiff(STime,HBr.StartNewDay,tmp);
      if (tmp>0) then begin
        vTimeDiff(HBr.StartNewDay,ETime,tmp);
        if (tmp>0) then begin
          Quantity = Quantity + 1;
        end;
      end;
    end;
    if (ETime>HBr.EndOfDay) then begin
      Quantity = Quantity + 1;
    end;
    if (SDate==EDate) then begin
      if ((STime>HBr.StartNewDay) and (ETime<HBr.EndOfDay)) then begin
        Quantity = Quantity + 1;
      end;
    end;
  end;
  NumberOfStayDays = Quantity;
  return;
end;

Related topics:
««