Scott Ribe wrote:

> NSDate * cd = [[NSCalendar currentCalendar] dateByAddingComponents: dc toDate: [NSDate dateWithString: @"2001-01-01"] options: 0];

I think the dateWithString: is wrong.  From the NSDate reference:

"You must specify all fields of the format string, including the time zone offset, which must have a plus or minus sign prefix."

Refactored code fragments:

NSDate * refDate1 = [NSDate dateWithString: @"2001-01-01"];
NSDate * refDate2 = [NSDate dateWithString: @"2001-01-01 00:00:00 +0000"];

NSLog( @"refDate1: %@", refDate1 );
NSLog( @"refDate2: %@", refDate2 );

...
NSDate * cd = [[NSCalendar currentCalendar] dateByAddingComponents: dc
  toDate: refDate1 options: 0];  // should be same as original

...
NSDate * cd = [[NSCalendar currentCalendar] dateByAddingComponents: dc
  toDate: refDate2 options: 0];

  -- GG

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to