• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Carbon Date to NSDate - Here's How
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Carbon Date to NSDate - Here's How
      • From: email@hidden
    • Re: Carbon Date to NSDate - Here's How
      • From: Rosyna <email@hidden>
References: 
 >Re: Carbon Date to NSDate - How? (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Overriding NSTextField problem
  • Next by Date: Re: Help with Help
  • Previous by thread: Re: Carbon Date to NSDate - How?
  • Next by thread: Re: Carbon Date to NSDate - Here's How
  • Index(es):
    • Date
    • Thread