• 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: Andrew Pinski <email@hidden>
  • Date: Tue, 26 Feb 2002 21:43:41 -0500

On Tuesday, February 26, 2002, at 07:14 , email@hidden wrote:

If you don't want to have such a cryptic constant in your code, you can
make the carbon epoch and use dateWithTimeIntervalSinceReferenceDate

+ (NSDate *)carbonEpoch
{
static NSCalendarDate *carbon_epoch;
if (carbon_epoch == nil)
carbon_epoch = [[NSCalendarDate dateWithYear:1904 month:1
day:1 hour:0 minute:0 second:0
timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]] retain];
return carbon_epoch;
}


Actually I would rewrite the class message so you do not need to put carbon_epoch in an autoreleasepool.
And also the carbonEpoch is usually in local time so you do need to the time zone to the local one.

+ (NSDate *)carbonEpoch
{
static NSDate *carbon_epoch;
if (carbon_epoch == nil)
carbon_epoch = [[NSCalendarDate alloc] initWithYear:1904 month:1
day:1 hour:0 minute:0 second:0 timeZone:[NSTimeZone localTimeZone]];
return carbon_epoch;
}
_______________________________________________
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: Finlay Dobbie <email@hidden>
References: 
 >Re: Carbon Date to NSDate - Here's How (From: email@hidden)

  • Prev by Date: Re: OS information
  • Next by Date: Re: notifications vs delegates (was: The fuzzy aspects of Cocoa)
  • Previous by thread: Re: Carbon Date to NSDate - Here's How
  • Next by thread: Re: Carbon Date to NSDate - Here's How
  • Index(es):
    • Date
    • Thread