fix gettimeofday (was off by one day)
This commit is contained in:
parent
beb4c2c518
commit
c124cf98d9
|
@ -276,7 +276,12 @@ int _gettimeofday_r(struct _reent *reent, struct timeval *tp, void *__tz)
|
||||||
|
|
||||||
if(tp)
|
if(tp)
|
||||||
{
|
{
|
||||||
tp->tv_sec = secs - 86400 * (365 * 66 + 66/4);
|
const int epochDifferenceInYears = 1970 - 1904;
|
||||||
|
const int epochDifferenceInDays =
|
||||||
|
365 * epochDifferenceInYears
|
||||||
|
+ (epochDifferenceInYears + 3)/ 4; // round up for leap years
|
||||||
|
|
||||||
|
tp->tv_sec = secs - 86400 * epochDifferenceInDays;
|
||||||
tp->tv_usec = (ticks - savedTicks) * 20000000 / 2003;
|
tp->tv_usec = (ticks - savedTicks) * 20000000 / 2003;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue