• 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
dateWithCalendarFormat: problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dateWithCalendarFormat: problem?


  • Subject: dateWithCalendarFormat: problem?
  • From: norio <email@hidden>
  • Date: Fri, 15 Feb 2008 17:13:57 +0900

Hi

I have an NSDatePicker, an NSTextField, and an NSButton on a window. Initially the DatePicker is supposed to display 1982/02/13.

My code converts the date of the DatePicker into NSCalendarDate using dateWithCalendarFormat:timeZonewhen and displays it in the text field as a text when you press the button. The code is here.


@interface appDelegator : NSObject { IBOutlet id dpicker; IBOutlet id dpickertext; }

- (IBAction) convertTheDate:(id)sender;
@end

@implementation appDelegator
- (IBAction) convertTheDate:(id)sender
{
   NSDate* theDate = [dpicker dateValue];
   NSCalendarDate * cDate;

   NSLog (@"%@",[theDate description]);

   cDate = [theDate dateWithCalendarFormat:nil timeZone:nil];
   [dpickertext setStringValue:[cDate description]];
}
@end

The problem is this:

If I typed "0" in the year part then typed 'tab', the DatePicker displayed 0001/02/13.
Isn't it correct? I thought I would be 0000/02/13.


Next, I pressed the button which calls the method above.

The NSTextField,'dpickertext', displayed '0-02-11 01:00:00 +0900'.
NSLog showed the below at the time.
2008-02-15 16:55:50.880 datepicker[1141:813] 0001-02-13 01:00:00 +0900


Then I typed "2008" in the year part then 'tab' at this time, the DatePicker displayed 2008/02/13. Good.


However if I pressed the button to convert it into NSCalendarDate using dateWithCalendarFormat:timeZone:, the text field displayed '-2007-01-27 01:00:00 +0900'.
NSLog showed the following.
2008-02-15 16:57:56.080 datepicker[1141:813] 2008-02-13 01:00:00 +0900


Would you tell me what I'm missing?

Thanks in advance.
Norio Ota

_______________________________________________

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: dateWithCalendarFormat: problem?
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: In-loop releasing of objects does not free memory?
  • Next by Date: Strategies to prevent class name clashes
  • Previous by thread: Re: PDFKit and PDF Overprint
  • Next by thread: Re: dateWithCalendarFormat: problem?
  • Index(es):
    • Date
    • Thread