Browse Source

+ Implemented ComposeDateTime for general use

git-svn-id: trunk@4007 -
joost 19 years ago
parent
commit
391dc9a9fb
2 changed files with 8 additions and 6 deletions
  1. 7 6
      rtl/objpas/sysutils/dati.inc
  2. 1 0
      rtl/objpas/sysutils/datih.inc

+ 7 - 6
rtl/objpas/sysutils/dati.inc

@@ -43,17 +43,18 @@ begin
     Result:=0;
 end;
 
+{==============================================================================}
+{   Public functions                                                           }
+{==============================================================================}
+
+{   ComposeDateTime converts a Date and a Time into one TDateTime   }
 function ComposeDateTime(Date,Time : TDateTime) : TDateTime;
 
 begin
-  if Date < 0 then Result := Date - Time
-  else Result := Date + Time;
+  if Date < 0 then Result := trunc(Date) - frac(Time)
+  else Result := trunc(Date) + frac(Time);
 end;
 
-{==============================================================================}
-{   Public functions                                                           }
-{==============================================================================}
-
 {   DateTimeToTimeStamp converts DateTime to a TTimeStamp   }
 
 function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;

+ 1 - 0
rtl/objpas/sysutils/datih.inc

@@ -101,6 +101,7 @@ function TryEncodeDate(Year, Month, Day: Word; var Date: TDateTime): Boolean;
 function TryEncodeTime(Hour, Min, Sec, MSec: Word; var Time: TDateTime): Boolean;
 function EncodeDate(Year, Month, Day :word): TDateTime;
 function EncodeTime(Hour, Minute, Second, MilliSecond:word): TDateTime;
+function ComposeDateTime(Date,Time : TDateTime) : TDateTime;
 procedure DecodeDate(Date: TDateTime; var Year, Month, Day: word);
 function DecodeDateFully(const DateTime: TDateTime; var Year, Month, Day, DOW: Word): Boolean;
 procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);