unixandroid.inc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 'c' name 'localtime';
  29. var
  30. c_tzname: array[0..1] of PAnsiChar; external 'c' name 'tzname';
  31. c_timezone: longint; external 'c' name 'timezone';
  32. c_daylignt: shortint; external 'c' 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
  43. begin
  44. tzdaylight:=tt^.tm_isdst <> 0;
  45. tzseconds:=tt^.tm_gmtoff;
  46. end
  47. else
  48. begin
  49. tzdaylight:=c_daylignt <> 0;
  50. tzseconds:=-c_timezone;
  51. end;
  52. end;