Re: Possible bug with NSDateFormatter??
Re: Possible bug with NSDateFormatter??
- Subject: Re: Possible bug with NSDateFormatter??
- From: Joseph Jones <email@hidden>
- Date: Fri, 23 May 2003 22:00:27 -0700
Terrific! Thanx, I will get this in my code ASAP.
joe
On Friday, May 23, 2003, at 07:56 PM, Emma Whan wrote:
It is a bug in the frameworks. I've mentioned it before in other
posts. The bug only comes into effect when the user has dd/mm/yy date
format (or some other format that has dates before months) and has
leading zeros in months turned off. The short date format string in
that case is "%e/%1m/%y". If you get rid of the "1" before the "m",
the problem is resolved. However, it does mean that leading zeros will
be displayed for months. Here is my code for working around the
problem:-
NSCell *dateDataCell = [[myOutlineView
tableColumnWithIdentifier:@"Date"] dataCell];
NSDateFormatter *dateFormatter;
NSMutableString *dateFormat =[[NSMutableString alloc]
initWithString:[[NSUserDefaults standardUserDefaults]
objectForKey:NSShortDateFormatString]];
//look for "1m" in formatstring and change it to "m" (to overcome a
Cocoa bug) if user has dates before months dd/mm/yy - don't strip the 1
if user has mm/dd/yy date order
NSRange rangeOf1m = [dateFormat rangeOfString: @"1m"];
if (rangeOf1m.length != 0 && rangeOf1m.location != 1)
{
[dateFormat replaceCharactersInRange:rangeOf1m
withString:@"m"];
}
dateFormatter = [[NSDateFormatter alloc]
initWithDateFormat:dateFormat allowNaturalLanguage:YES];
[dateDataCell setFormatter: dateFormatter];
[dateFormatter release];
[dateFormat release];
On Friday, May 23, 2003, at 03:48 AM,
email@hidden wrote:
Date: Thu, 22 May 2003 10:29:09 -0700
Subject: Possible bug with NSDateFormatter??
From: Joseph Jones <email@hidden>
To: Cocoa Dev Dev <email@hidden>
Hi all,
I am using an NSDateFormatter on one of my NSOutlineView columns. I am
setting the formatter format to the system local short date format (in
this case DD.MM.YYYY). Everything displays fine. However, when I try
to
input date info in the same format (DD.MM.YYYY), the formatter will
either swap DD and MM, or refuse to accept the input if DD > 12. It
appears that the formatter, irregardless of format settings, is
requiring date input in MM.DD.YYYY format. This seems to be a bug to
me
and something that is causing my users much heart ache. Am I doing
something wrong here, or is this a real bug with the frameworks?
Thanx,
joe
_______________________________________________
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.
_______________________________________________
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.