[Lazarus] How to get UTC time
Petr Hlozek
petr at ok2cqr.com
Sun Jul 24 15:05:42 CEST 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I need to get UTC time from my system. Using Ubuntu 10.04 with fpc 2.4.0.
Trying this function:
function utc_now : TDateTime;
var
timeval: TTimeVal;
timezone: PTimeZone;
a: Double;
begin
TimeZone := nil;
fpGetTimeOfDay (@TimeVal, TimeZone);
a := (TimeVal.tv_sec * 1000.0) + (TimeVal.tv_usec / 1000.0);
Result := (a / MSecsPerDay) + UnixDateDelta;
end;
It's working but it returns right time only for the first time. Next
calling utc_now() returns the same time as before.
Does anybody know what is wrong?
Thank you!
Petr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJOLBimAAoJEFxZOIHWsemF27QIAJJbhwMGligZhzA7zuwaFoc8
sJzXlIF5RNnn6Jj4cii5RtFFIe64c+3RM5lXq7mSPOX6t20KtUucG5oCe+lkekIP
wQWvvwiVmEXjOazGQAW5JWRy821S5FSYTySFseqW0W6lO0Qby7duUgZMC4zJTsha
DM/ZIBbvjVuNs36ckPxsYu2T+h6jqRTcqbfD1XGBnj13Zi8TjbMdOCacfZuAIxZt
u8nxvLQStCl0DD7Rtx7MdSb1+Ygir0jU7/PQ/GLqpkt4P6iOAg4mE8kSpe1ZPCGi
6DlGas3cD9KnuDRg81pbslKrb1fPb0IBkj95UUAI+rZQ1F5hHXwwdD+irgz9tL8=
=4WAF
-----END PGP SIGNATURE-----
More information about the Lazarus
mailing list