Re: Using NSAppleEventDescriptor with NSDates
Re: Using NSAppleEventDescriptor with NSDates
- Subject: Re: Using NSAppleEventDescriptor with NSDates
- From: Mike Abdullah <email@hidden>
- Date: Sat, 9 Sep 2006 18:03:06 +0100
This was a thread around 8 months ago. I was looking for a way to
get an NSAppleEventDescriptor of an NSDate. Matt Neuberg suggested a
solution:
Hint: An 'ldt ' (note the space) is a LongDateTime, which is a
signed 64-bit
integer representing the number of seconds since the start of 1904.
You may
find the utilities on this page helpful:
And I have now (finally) achieved this.
The reason I'm posting this is that there is still nothing really
helpful on this on Google, so I figured for the archives I'd post my
category for doing this.
Mike.
@implementation NSAppleEventDescriptor (NSDate)
+ (NSAppleEventDescriptor *)descriptorWithDate:(NSDate *)date
{
return [[[[self class] alloc] initWithDate: date] autorelease];
}
- (id)initWithDate:(NSDate *)date
{
// Get the time interval since 1st Jan 2001 of the date
CFAbsoluteTime timeInterval = CFDateGetAbsoluteTime((CFDateRef)date);
// Convert the time interval to a long date
LongDateTime longDate;
UCConvertCFAbsoluteTimeToLongDateTime(timeInterval, &longDate);
// Build the descriptor
return [self initWithDescriptorType: 'ldt '
bytes: &longDate
length: sizeof(longDate)];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden