Browse Source

+ Small fixes. Moved getlocaltime to system-dependent files

michael 26 years ago
parent
commit
a7bb45265d
2 changed files with 31 additions and 48 deletions
  1. 20 37
      rtl/objpas/dati.inc
  2. 11 11
      rtl/objpas/sysstr.inc

+ 20 - 37
rtl/objpas/dati.inc

@@ -30,35 +30,6 @@ const
       ((0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334),
       ((0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334),
        (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335));
        (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335));
 
 
-Procedure GetLocalTime(var SystemTime: TSystemTime);
-{$IFDEF GO32V2}
-var Regs: Registers;
-begin
-Regs.ah := $2C;
-RealIntr($21, Regs);
-SystemTime.Hour := Regs.Ch;
-SystemTime.Minute := Regs.Cl;
-SystemTime.Second := Regs.Dh;
-SystemTime.MilliSecond := Regs.Dl;
-Regs.ah := $2A;
-RealIntr($21, Regs);
-SystemTime.Year := Regs.Cx;
-SystemTime.Month := Regs.Dh;
-SystemTime.Day := Regs.Dl;
-end ;
-{$ELSE}
-{$IFDEF LINUX}
-begin
-linux.GetTime(SystemTime.Hour, SystemTime.Minute, SystemTime.Second);
-linux.GetDate(SystemTime.Year, SystemTime.Month, SystemTime.Day);
-SystemTime.MilliSecond := 0;
-end ;
-{$ELSE}
-begin
-end ;
-{$ENDIF}
-{$ENDIF}
-
 function DoEncodeDate(Year, Month, Day: Word): longint;
 function DoEncodeDate(Year, Month, Day: Word): longint;
 var i: longint;
 var i: longint;
 begin
 begin
@@ -160,14 +131,23 @@ end ;
     Hour, Minute, Second and MilliSecond    }
     Hour, Minute, Second and MilliSecond    }
 
 
 procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);
 procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);
-var l:longint;
+var l:TDateTime;
+
 begin
 begin
-l := Trunc(Frac(time) * MSecsPerDay);
-Hour   := l div 3600000;l := l mod 3600000;
-Minute := l div 60000;l := l mod 60000;
-Second := l div 1000;l := l mod 1000;
-MilliSecond := l;
-end ;
+{ l := Trunc(Frac(time) * MSecsPerDay);
+ Hour   := l div 3600000;l := l mod 3600000;
+ Minute := l div 60000;l := l mod 60000;
+ Second := l div 1000;l := l mod 1000;
+ MilliSecond := l;
+}
+  Time := Frac(Time) * 24;
+  Hour := Trunc(Time);
+  Time := Frac(Time) * 60;
+  Minute  := Trunc(Time);
+  Time := Frac(Time) * 60;
+  Second  := Trunc(Time);
+  MilliSecond := Trunc(Frac(Time) * 1000);
+end;
 
 
 {   DateTimeToSystemTime converts DateTime value to SystemTime   }
 {   DateTimeToSystemTime converts DateTime value to SystemTime   }
 
 
@@ -625,7 +605,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.7  1999-02-10 22:15:10  michael
+  Revision 1.8  1999-02-24 15:56:28  michael
+  + Small fixes. Moved getlocaltime to system-dependent files
+
+  Revision 1.7  1999/02/10 22:15:10  michael
   + Changed to ansistrings
   + Changed to ansistrings
 
 
   Revision 1.6  1999/02/09 12:38:42  michael
   Revision 1.6  1999/02/09 12:38:42  michael

+ 11 - 11
rtl/objpas/sysstr.inc

@@ -26,32 +26,29 @@
 
 
 function NewStr(const S: string): PString;
 function NewStr(const S: string): PString;
 begin
 begin
-result := Nil;
-{
-if Length(S) <> 0 then begin
-   result := New(PString);
-   result^ := S;
-   end ;
-}
+  result := Nil; 
+  if Length(S) <> 0 then 
+    begin
+    New(Result);
+    result^ := S;
+    end ;
 end ;
 end ;
 
 
 {   DisposeStr frees the memory occupied by S   }
 {   DisposeStr frees the memory occupied by S   }
 
 
 procedure DisposeStr(S: PString);
 procedure DisposeStr(S: PString);
 begin
 begin
-{
 if S <> Nil then begin
 if S <> Nil then begin
    Dispose(S);
    Dispose(S);
    S := Nil;
    S := Nil;
    end ;
    end ;
-}
 end ;
 end ;
 
 
 {   AssignStr assigns S to P^   }
 {   AssignStr assigns S to P^   }
 
 
 procedure AssignStr(var P: PString; const S: string);
 procedure AssignStr(var P: PString; const S: string);
 begin
 begin
-P^ := s;
+  P^ := s;
 end ;
 end ;
 
 
 {   AppendStr appends S to Dest   }
 {   AppendStr appends S to Dest   }
@@ -880,7 +877,10 @@ end ;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.11  1999-02-10 22:15:12  michael
+  Revision 1.12  1999-02-24 15:56:29  michael
+  + Small fixes. Moved getlocaltime to system-dependent files
+
+  Revision 1.11  1999/02/10 22:15:12  michael
   + Changed to ansistrings
   + Changed to ansistrings
 
 
   Revision 1.10  1998/12/15 22:43:09  peter
   Revision 1.10  1998/12/15 22:43:09  peter