From: "Jamie Frater" Subject: Re: DateTime problem (again) (UnixDate -> TDateTime) Date: 15 Dec 1999 00:00:00 GMT Message-ID: <837hmi$88411@forums.borland.com> References: <836jbl$42a5@forums.borland.com> <836q6s$42a12@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Reply-To: "Jamie Frater" Newsgroups: borland.public.delphi.objectpascal Many thanks Philippe - this works brilliantly. I have pasted the new version of the method below for others who may wish to also use it. Jamie. function UnixTimeToDateTime(UnixTime: Double; UTC: Boolean): TDateTime; var SysTime, TmpSysTime: TSystemTime; DTime: TDateTime; FTime, LTime: TFileTime; begin DTime := (UnixTime / (24 * 3600)) + EncodeDate(1970, 1, 1); if UTC = true then result := DTime else begin DateTimeToSystemTime(DTime, TmpSysTime); // SystemTimeToTzSpecificLocalTime(@TimeZoneInformation, TmpSysTime, SysTime); // The above commented line only works on WinNT, // philippe Ranger suggested the following fix. SystemTimeToFileTime(TmpSysTime, FTime); FileTimeToLocalFileTime(FTime, LTime); FileTimeToSystemTime(LTime, SysTime); result := SystemTimeToDateTime(sysTime); end; end; If you want the result in Coordinated Universal Time, set UTC to true, otherwise specify false. wrote in message news:836q6s$42a12@forums.borland.com... > < The problem is the call to SystemTimeToTzSpecificLocalTime. This > API fails (according to the help file) everywhere except WinNT. > > >> > > The only thing special about SystemTimeToTz... is that it converst > systemTime to systemTime. You can instead convert -- > > (UTC) SystemTimeToFileTime(); > FileTimeToLocalFileTime(); > FileTimeToSystemTime(); > > PhR