• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Two digit dates with NSDateFormatter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Two digit dates with NSDateFormatter
      • From: Matthew Lindfield Seager <email@hidden>
  • Prev by Date: Re: Rounded NSBox/NSView?
  • Next by Date: Re: Rounded NSBox/NSView?
  • Previous by thread: Re: How to check if a class derives from another?
  • Next by thread: Re: Two digit dates with NSDateFormatter
  • Index(es):
    • Date
    • Thread