Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FpGetTimeOfDay gives no timezone
#5
Thanks again.

Indeed, I missed the /24 part. This is why putting that directly to IdGlobal did not work. Now it does. So the fix I have now is easy and simple:
Removed 7355-7357
// var
// timeval: TTimeVal;
// timezone: TTimeZone;
And also 7412-13, but added the corrected new line:
// fpGetTimeOfDay (@TimeVal, @TimeZone);
// Result := -1 * (timezone.tz_minuteswest / 60 / 24);
Result:=-1 * (GetLocalTimeOffset/60/24);

I am aware of the problem, that if daylight saving changes, the bias is not updated automatically. It is not good, but I can live with it for the time being.

As you first suggested, I tried, but could not make it work with localtime_r() as it keeps missing declarations, localtime_r(), TUnixTime. If understood correctly they should be in LibC (deprecated), but could not link it. I did not find it in my platform in RTL. If you can help me, how to do it, I will try again. If we want to use localtime_r(), best would be to declare it in an easily available unit centrally.

The old bugs you mentioned were fixed in FPC, The confusion is always whether bias should be added to or deducted from localtime to get UTC.

Just for curiosity. You wrote (and now I also did):
Result:=-1 * (GetLocalTimeOffset/60/24);
Normally I would write:
Result:=-GetLocalTimeOffset/60/24; // (no -1* just - and no brackets)
Is it a convention or good programming practice, or why? Obviously the other works as well, just the same.

Thanks again,
Reply


Messages In This Thread
FpGetTimeOfDay gives no timezone - by jollytall - 01-04-2019, 03:59 PM
RE: FpGetTimeOfDay gives no timezone - by rlebeau - 01-06-2019, 08:00 PM
RE: FpGetTimeOfDay gives no timezone - by rlebeau - 01-14-2019, 09:15 PM
RE: FpGetTimeOfDay gives no timezone - by jollytall - 01-15-2019, 07:25 AM
RE: FpGetTimeOfDay gives no timezone - by rlebeau - 01-15-2019, 06:22 PM
RE: FpGetTimeOfDay gives no timezone - by rlebeau - 01-19-2019, 01:18 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)