Re: Carbon Date to NSDate - Here's How
Re: Carbon Date to NSDate - Here's How
- Subject: Re: Carbon Date to NSDate - Here's How
- From: John Pattenden <email@hidden>
- Date: Mon, 25 Feb 2002 15:36:19 -0800
I ended up doing this
myCorrectedDate = myCarbonDate - 0xB6757900;
myCocoaDate = [NSDate dateWithTimeIntervalSinceReferenceDate: myCorrectedDate];
0xB6757900 is the hex difference between the carbon epoch and the
standard cocoa epoch...
On Monday, February 25, 2002, at 11:20 AM, John Pattenden wrote:
I have a carbon app that sends a ulong date to my cocoa code, is
there a simple way to convert from Carbon's date format to cocoas??
Depending on just what the epoch is for that unsigned long, assuming
that value is seconds since the epoch, you can do it like this:
unsigned long carbonDate;
double interval = carbonDate;
NSDate myDate = [NSDate dateWithTimeIntervalSinceReferenceDate:interval];
or this:
NSDate myDate = [NSDate dateWithTimeIntervalSince1970:interval];
See which one works.
HTH,
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
John Pattenden
ScreenTime Media
http://www.screentime.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.