From ba45339b0cda696438a3b1553c829445fd894641 Mon Sep 17 00:00:00 2001
From: beware <beware@bircd.org>
Date: Sun, 23 Feb 2020 19:27:13 +0000
Subject: [PATCH 1/1] make unixtimeint and unixtimefloat work after 2038 on 32
 bits unix. timezone is still broken.

git-svn-id: file:///svnroot/lcore/trunk@155 b1de8a11-f9be-4011-bde0-cc7ace90066a
---
 btime.pas | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/btime.pas b/btime.pas
index 46cdf48..a0bfc5e 100644
--- a/btime.pas
+++ b/btime.pas
@@ -176,9 +176,14 @@ end;
 function unixtimefloat:float;
 var
   tv:ttimeval;
+  sec:tunixtimeint;
 begin
   gettimeofday(tv);
-  result := tv.tv_sec+(tv.tv_usec/1000000);
+  sec := tv.tv_sec;
+  {$ifndef cpu64}
+  if (sec < 0) then inc(sec,$100000000); //tv_sec is 32 bits
+  {$endif}
+  result := sec+(tv.tv_usec/1000000);
 end;
 
 {$ifdef linux}
@@ -263,9 +268,14 @@ end;
 function unixtimeint:tunixtimeint;
 var
   tv:ttimeval;
+  sec:tunixtimeint;
 begin
   gettimeofday(tv);
-  result := tv.tv_sec;
+  sec := tv.tv_sec;
+  {$ifndef cpu64}
+  if (sec < 0) then inc(sec,$100000000); //tv_sec is 32 bits
+  {$endif}
+  result := sec;
 end;
 
 {------------------------------ end of *nix/freepascal section}
-- 
2.30.2