mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 07:49:32 +01:00
* fixed datetime related routines for unix
git-svn-id: trunk@444 -
This commit is contained in:
parent
c92377604c
commit
437f35315c
@ -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;
|
||||
|
||||
@ -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.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user