Hi,

im running into some very odd behavior when using a ShortStyle date formatter for entering dates, and using single vs double digit year numbers. typing the year as either "2009" or "09" works as expected, but typing it as "9" not only does *not adjust the century, but also produces what i'd consider an invalid date. see the following code and output:

----
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setTimeStyle:NSDateFormatterNoStyle];
    [dateFormatter setDateStyle:NSDateFormatterShortStyle];

    NSDate *date1 = [dateFormatter dateFromString:@"1/1/9"];
    NSDate *date2 = [dateFormatter dateFromString:@"1/1/09"];

    NSLog(@"Date1:1/1/9:  %@", date1);
    NSLog(@"Date2:1/1/09: %@", date2);
----
2009-11-03 16:20:19.886 NSDateFormatterTest[33780:a0f] Date1:1/1/9: 0009-01-01 00:00:00 +020204 2009-11-03 16:20:19.888 NSDateFormatterTest[33780:a0f] Date2:1/1/09: 2009-01-01 00:00:00 +0200

note how date1 not only has the year as "0009", but a timezone of +020204.

this is made worse by the fact that the date *looks* ok (and indistinguishable from the "good" one when displayed thru the NSDataFormatter (say in an NSTableView cell)

is this behavior expected? am i doing something wrong? or is this a bug? can anyone else reproduce this?

thanx,
marc
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to