Re: UpTime broken?
Re: UpTime broken?
- Subject: Re: UpTime broken?
- From: David <email@hidden>
- Date: Tue, 1 Nov 2005 14:54:39 -0600
Good call. This is on a powerbook so it has gone to sleep. It also
appears all the macho_time calls are affected as well.
I've changed the routine to the following and all is working as
expected:
UInt64 CurrentTimeInMilliseconds()
{
struct timeval currentTime;
gettimeofday(¤tTime, NULL);
UInt64 i = currentTime.tv_sec;
i *= 1000000; // make room for microseconds
i += currentTime.tv_usec;
i /= 1000; // convert to milliseconds
return i;
}
On Nov 1, 2005, at 12:57 PM, Andrew Farmer wrote:
On 01 Nov 05, at 09:24, David wrote:
The currentDate is correct if the computer has an uptime of less
than 1 day. After that it is off by aprox. 2 hours and may get
worse the longer the computer is on.
Are you sure your computer isn't going to sleep? It's possible that
UpTime might not count time spent in sleep, while sysctl
(KERN_BOOTTIME) just tells you the starting time.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden