Re: NSDate isEqual to...
Re: NSDate isEqual to...
- Subject: Re: NSDate isEqual to...
- From: "Charles E. Heizer" <email@hidden>
- Date: Fri, 20 Mar 2009 16:54:23 -0700
Thanks a bunch for clearing this all up for me. I have converted my
test code to use "timeIntervalSince1970" and it appears to be working
fine. My main concern is starting from a specific point in time and
then have a reliable and consistent interval to count on.
Thanks again,
Charles
On Mar 20, 2009, at 3:46 PM, mm w wrote:
Right the comment of Mike is fair,
I don't know what you are doing (a lie), anyway your interest is to
know a time interval rather than a date
you should design a object with a referential start-time:
CFAbsoluteTime timeNow(void)
{
return (CFAbsoluteTime) (CFAbsoluteTimeGetCurrent() -
kCFAbsoluteTimeIntervalSince1970);
// you have similar access thru Cocoa
}
and use only NSDate (rather than to play with it, it's also a main
memory consumer) to make a representation of this time interval at
(T), I think it will save you a lot of pain
for the next time... :)
Cheers!
On Fri, Mar 20, 2009 at 2:50 PM, Mike Abdullah
<email@hidden> wrote:
On 20 Mar 2009, at 21:17, Charles E. Heizer wrote:
Thanks,
No it's just playing around right now. It would be nice to be able
to
specify if you wanted NSDate to be sub-second or second precision
based.
Just as question, can NSDate be overridden to be second precision
based?
Theoretically yes. Practically, it would be a rather bad idea. 1
second is
meaningful to you, but consider a completely different culture's
calendaring
system where "a second" is actually equivalent to 3 of ours
seconds. What
would second precision be then?
The point is that you don't really want to test the equality of two
dates.
Instead you want to compare them like so:
date1 >= date2
date1 <= date2
Or you want to know if they're roughly equal to each other. "Is
date1 within
0.5 seconds of date2"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
@gmail.com
This email sent to email@hidden
--
-mmw
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden