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: 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.