Browse Source

* fixed datetime related routines for unix

git-svn-id: trunk@444 -
Jonas Maebe 20 years ago
parent
commit
437f35315c
2 changed files with 15 additions and 1 deletions
  1. 14 0
      rtl/objpas/sysutils/dati.inc
  2. 1 1
      rtl/unix/sysutils.pp

+ 14 - 0
rtl/objpas/sysutils/dati.inc

@@ -720,6 +720,7 @@ Var YY,MM,DD,H,m,s,msec : Word;
 
 begin
   Decodedate (DateTime,YY,MM,DD);
+{$ifndef unix}
   If (YY<1980) or (YY>2099) then
     Result:=0
   else
@@ -728,11 +729,16 @@ begin
     Result:=(s shr 1) or (m shl 5) or (h shl 11);
     Result:=Result or DD shl 16 or (MM shl 21) or ((YY-1980) shl 25);
     end;
+{$else unix}
+  Decodetime(DateTime,h,m,s,msec);
+  Result:=LocalToEpoch(yy,mm,dd,h,m,s);
+{$endif unix}
 end;
 
 
 Function FileDateToDateTime (Filedate : Longint) : TDateTime;
 
+{$ifndef unix}
 Var Date,Time : Word;
 
 begin
@@ -741,6 +747,14 @@ begin
   Result:=EncodeDate((Date shr 9) + 1980,(Date shr 5) and 15, Date and 31) +
           EncodeTime(Time shr 11, (Time shr 5) and 63, (Time and 31) shl 1,0);
 end;
+{$else unix}
+var
+  y, mon, d, h, min, s: word;
+begin
+  EpochToLocal(FileDate,y,mon,d,h,min,s);
+  Result:=EncodeDate(y,mon,d) + EncodeTime(h,min,s,0);
+end;
+{$endif unix}
 
 
 function TryStrToDate(const S: string; out Value: TDateTime): Boolean;

+ 1 - 1
rtl/unix/sysutils.pp

@@ -40,7 +40,7 @@ Procedure AddDisk(const path:string);
 implementation
 
 Uses
-  {$ifdef FPC_USE_LIBC}initc{$ELSE}Syscall{$ENDIF}, Baseunix;
+  {$ifdef FPC_USE_LIBC}initc{$ELSE}Syscall{$ENDIF}, Baseunix, unixutil;
 
 {$Define OS_FILEISREADONLY} // Specific implementation for Unix.