unixandroid.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by Yury Sidorov,
  4. member of the Free Pascal development team.
  5. Android-specific part of the System unit.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. type
  13. Ptm = ^tm;
  14. tm = record
  15. tm_sec : longint;
  16. tm_min : longint;
  17. tm_hour : longint;
  18. tm_mday : longint;
  19. tm_mon : longint;
  20. tm_year : longint;
  21. tm_wday : longint;
  22. tm_yday : longint;
  23. tm_isdst : longint;
  24. case boolean of
  25. false : (tm_gmtoff : longint;tm_zone : Pchar);
  26. true : (__tm_gmtoff : longint;__tm_zone : Pchar);
  27. end;
  28. function localtime(t: PLongInt): Ptm; cdecl; external;
  29. var
  30. c_tzname: array[0..1] of PAnsiChar; external name 'tzname';
  31. c_timezone: longint; external name 'timezone';
  32. c_daylignt: shortint; external name 'daylight';
  33. procedure InitLocalTime;
  34. var
  35. t: longint;
  36. tt: Ptm;
  37. begin
  38. t:=fptime;
  39. tt:=localtime(@t);
  40. tzname[false]:=c_tzname[0];
  41. tzname[true]:=c_tzname[1];
  42. if tt <> nil then begin
  43. tzdaylight:=tt^.tm_isdst <> 0;
  44. tzseconds:=tt^.tm_gmtoff;
  45. end
  46. else begin
  47. tzdaylight:=c_daylignt <> 0;
  48. tzseconds:=-c_timezone;
  49. end;
  50. end;