Procedure

TfrmVitals.BeginEndDates

Module

fVitals

Last Modified

7/15/2014 3:26:40 PM

Visibility

Public/Published

Owner

TfrmVitals

Declaration

procedure BeginEndDates(var ADate1, ADate2: TFMDateTime; var ADaysBack: integer);

Calls Hierarchy


TfrmVitals.BeginEndDates
 ├TfrmVitals.FMToDateTime
 └FMToday
   └FMNow

Called-By Hierarchy


          TfrmVitals.BeginEndDates
        TfrmVitals.lstDatesClick┘ 
           TfrmVitals.FormShow┤   
TfrmVitals.btnEnterVitalsClick┘   

Calls

Name Declaration Comments
TfrmVitals.FMToDateTime function FMToDateTime(FMDateTime: string): TDateTime; -
FMToday function FMToday: TFMDateTime; -

Called-By

Name Declaration Comments
TfrmVitals.lstDatesClick procedure lstDatesClick(Sender: TObject); -


Source

753   procedure TfrmVitals.BeginEndDates(var ADate1, ADate2: TFMDateTime; var ADaysBack: integer);
754   var
755     datetemp: TFMDateTime;
756     today, datetime1, datetime2: TDateTime;
757     relativedate: string;
758   begin
759     today := FMToDateTime(floattostr(FMToday));
760     relativedate := Piece(lstDates.ItemID, ';', 1);
761     relativedate := Piece(relativedate, '-', 2);
762     ADaysBack := strtointdef(relativedate, 0);
763     ADate1 := DateTimeToFMDateTime(today - ADaysBack);
764     relativedate := Piece(lstDates.ItemID, ';', 2);
765     if StrToIntDef(Piece(relativedate, '+', 2), 0) > 0 then
766       begin
767         relativedate := Piece(relativedate, '+', 2);
768         ADaysBack := strtointdef(relativedate, 0);
769         ADate2 := DateTimeToFMDateTime(today + ADaysBack + 1);
770       end
771     else
772       begin
773         relativedate := Piece(relativedate, '-', 2);
774         ADaysBack := strtointdef(relativedate, 0);
775         ADate2 := DateTimeToFMDateTime(today - ADaysBack);
776       end;
777     datetime1 := FMDateTimeToDateTime(ADate1);
778     datetime2 := FMDateTimeToDateTime(ADate2);
779     if datetime1 < datetime2 then                 // reorder dates, if needed
780       begin
781         datetemp := ADate1;
782         ADate1 := ADate2;
783         ADate2 := datetemp
784       end;
785     ADate1 := ADate1 + 0.2359;
786   end;