views:

31

answers:

0

Hi all, I have a feeling this is due to some time zone not being set or something this is what I have:

NSDateComponents *theComponents = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:workingDate];
NSLog(@"%d", theComponents.day);
[theComponents setDay:3];
NSLog(@"%d", theComponents.day);
self.workingDate = [calendar dateFromComponents:theComponents];
NSLog(@"%@", workingDate);

which outputs:

13
3
2010-10-02 14:00:00 GMT

I thought it would be a timezone issue so I used:

[calendar setTimeZone:[NSTimeZone systemTimeZone]];
[theComponents setTimeZone:[NSTimeZone systemTimeZone]];

and to try and fix it I used the different timezones like localTimeZone and defaultTimeZone but this makes no difference to the output. Anyone know whats going on?

EDIT: This is my calendar btw:

calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

and the date should be 2010-10-03