On Thursday, November 03, 2011 03:11:37 pm Hans-Peter Diettrich wrote: > Pete Cervasio schrieb: > > > Splitting the TDateTime into year, month etc. is done by a > > > DecodeDate... > > > > > > function, that *assumes* that TDateTime contains a local time. When > > > you > > > > > > feed it an UTC time, the result is unusable. > > > > What? How does it assume it's in local time? It assumes it has received > > the value you want decoded. The value 40850.5 treated as a TDateTime is > > 03 NOV 2011 @ 12:00. > > How do you get the starting date and time of the epoch?
With the constant UnixDateDelta. Help says that it "Specifies the difference between TDateTime and TIME_T values". Here's how I use it. My main software project does all its work in UTC so I use this utc_now rather than the built-in now. Conversion to local time is done only for display or logging purposes. function utc_now: TDateTime; var TimeVal: TTimeVal; TimeZone: PTimeZone; begin TimeZone := nil; GetTimeOfDay (TimeVal, TimeZone); Result := (TimeVal.tv_Sec / SecsPerDay) + ((TimeVal.tv_usec / 1000.0) / MSecsPerDay) + UnixDateDelta; end; Best regards, Pete C.
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel