[fpc-pascal] DateTimeToFileDate
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Sep 14 11:33:44 CEST 2008
On Sun, 14 Sep 2008 10:38:25 +0200
"Carsten Bager" <carsten at beas.dk> wrote:
> > AFAIK the unit Dos should not be used under Linux.
> >
> >
> > Mattias
>
> I rewrote the code omitting the dos unit, and got the fowing.
> In my opinion the windows output and the Linux output should be
> (almost) the same, and then my conclusion is a compiler/rtl error.
> Do you agree (I have also tested the 2.2.0 compiler and got the same
> result).
The FileDate format differ on unix and windows. UnpackTime uses the
windows format. You need another function for unix.
Mattias
>
> Carsten
>
>
> Output from Linux compiler
>
> Free Pascal Compiler version 2.2.0 [2007/08/31] for i386
> Target OS: Linux for i386
> 12/6-2016 25:14:58
> 14-9-08 10:22:53
>
> Output from Windows Compiler
> Free Pascal Compiler version 2.2.2 [2008/08/03] for i386
> Target OS: Win32 for i386
>
> 14/9-2008 10:21:42
> 14-09-2008 10:21:42
>
>
> ----------------------------------
>
> Program tt;
> uses sysutils;
>
> Type
> Datetime_typ=Packed record
> year,month,day,hour,min,sec,sec100,dayOfWeek:word;
> end;
>
> procedure UnpackTime(pdt:LongWord; var d:dateTime_typ);
> begin
> d.sec:=(pdt and 31) *2;
> pdt:=pdt shr 5;
> d.min:=pdt and 63;
> pdt:=pdt shr 6;
> d.hour:=pdt and 31;
> pdt:=pdt shr 5;
> d.day:=pdt and 31;
> pdt:=pdt shr 5;
> d.month:=pdt and 15;
> pdt:=pdt shr 4;
> d.year:=pdt+1980;
> end;
>
> function strPackTime(t:longWord):shortstring;
> var
> dt:Datetime_typ;
> begin
> UnpackTime(t,dt);
> strPackTime:=intToStr(dt.day)+'/'+
> intToStr(dt.month)+'-'+
> intToStr(dt.year)+' '+
> intToStr(dt.hour)+':'+
> intToStr(dt.min)+':'+
> intToStr(dt.sec)+' ';
> end;
>
> Begin
> WriteLn(strPackTime(DateTimeToFileDate(now)));
>
> WriteLn(DateTimeToStr(FileDateToDateTime(DateTimeToFileDate(now))))
> ;
> End.
> ------------------------------------
> Med venlig hilsen
> Carsten Bager
>
> BEAS A/S
> Brørupvænget 10
> DK-7650 Bøvlingbjerg
> Tlf. : +45 9788 5222 Fax : +45 9788 5434
> www.beas.dk
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list