Re: Intelligent date squishing
Re: Intelligent date squishing
- Subject: Re: Intelligent date squishing
- From: August Trometer <email@hidden>
- Date: Mon, 8 Aug 2005 17:28:02 -0500
I think the best way to do this is to use a custom class for the
table cell in question. Here's the solution I came up with. It's good
for 10.3 as well as 10.4, but it doesn't do any sort of localizing.
If you're writing for 10.4, you could use the new dateStyle
constants, which would probably be better.
This may not be the best solution -- I'm sure someone will be happy
to point out the flaws ;)
@implementation TMDateCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
{
int width = cellFrame.size.width;
NSString *formatString;
if (width < 130)
formatString = @"%m/%d/%Y";
else if (width < 145)
formatString = @"%m/%d/%Y, %I:%M %p";
else if (width < 170)
formatString = @"%b %d, %Y, %I:%M %p";
else if (width < 200)
formatString = @"%B %d, %Y, %I:%M %p";
else
formatString = @"%A, %B %d, %Y, %I:%M %p";
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]
initWithDateFormat:formatString allowNaturalLanguage:YES] autorelease];
[self setFormatter:dateFormat];
[super drawWithFrame:cellFrame inView:controlView];
}
@end
-- August
On Aug 5, 2005, at 1:15 PM, Theodore H. Smith wrote:
I'm wondering how the Finder will "Squish" the dates if they are
too big to be displayed in the current format. Is this a standard
NSDateFormatter functionality or must I implement it myself?
_______________________________________________
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