Two digit dates with NSDateFormatter
Two digit dates with NSDateFormatter
- Subject: Two digit dates with NSDateFormatter
- From: Matthew Lindfield Seager <email@hidden>
- Date: Tue, 6 Oct 2009 14:30:26 +1100
Hi All,
I have a 10.4 style date formatter applied to an NSTextFieldCell. I
call setTwoDigitStartDate: (tried with both the epoch date and the
"reference" date) but when I type a date with a two digit year in it sets
the year to 0009 instead of 2009. Am I missing something obvious?
Regards,
Matt
//.h
IBOutlet NSTextFieldCell *transactionDateField; // this outlet *IS* set
correctly in IB
//.m
- (void)awakeFromNib {
NSDate *startDate = [NSDate dateWithTimeIntervalSinceReferenceDate:0];
//NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:0]; // also
tried this
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormat setDateStyle:NSDateFormatterMediumStyle];
[dateFormat setTwoDigitStartDate:startDate];
[dateFormat setLenient:YES];
[transactionDateField setFormatter:dateFormat];
}
--
Safe, comfortable and satisfied? Please consider supporting some people who
aren't!
I'm riding 100 kilometres to raise funds for refugees!
http://my.e2rm.com/personalPage.aspx?registrationID=750445
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden