site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Importance: Normal Noah and group, You're right, it does return UTC. You're also right about why I thought I was getting local time. I was "doing something stupid when you determine what time those seconds represent". I really appreciate everyone's help. Sorry about the incorrect report. Michael
-----Original Message----- From: noah williamsson [mailto:noah@hd.se] Sent: Friday, December 03, 2004 11:18 AM To: Michael Rubinstein Cc: darwin-dev@lists.apple.com Subject: Re: gettimeofday() seems to return local time
Hi Michael,
Michael Rubinstein wrote:
I'm using gettimeofday(), on OS X 10.3.6, to get the time resolution I need (milliseconds).
If I'm reading the documentation right, I should be getting time in UTC. However, I'm getting local time.
Gettimeofday() with NULL as second argument always returns time in UTC. If it does not, either the clock and timezone on your machine is wrong or you're doing something stupid when you determine what time those seconds represent. Like using ctime() for example, which prints the time according to the local timezone.
The man page for gettimeofday() on 10.3.6 also says this about the second argument: "Note: timezone is no longer used; this information is kept outside the kernel." I assume they want you to use tzset() and functions from time.h instead.
On a sidenote, there was a bug before 10.3 where chrooted processes weren't able to determine the local time correctly even though tzset() had been used prior to the call to chroot().
-- noah
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com