I'm working with some NSDate objects, and well, I use my iPhone with 24 hrs format, so when I was testing my app, everything went fine, but, one of my friends tried the app on his iPhone, but he uses 12hrs format, after some research I found out that the problem was the date, and I have no idea why I use this to set a date picker and a time picker, so I read some values from a database (yes, I've checked the values and they are correct, it is not a value-issue), so all this data is formatted and put together as a NSDate, then, I set the date picker and time picker with this date I just created
NSDateFormatter *currentDate = [[[NSDateFormatter alloc] init] autorelease];
[currentDate setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate * startDate =[currentDate dateFromString:[NSString stringWithFormat:@"%d-%d-%d %d:%d",yearVal,monthVal,dayVal,hourVal,minVal]];
[datePicker setDate:startDate];
[timePicker setDate:startDate];
So, yearVal, monthVal, dayVal, hourVal, minVal are all NSIntegers... the thing is, that, it perfectly works if your iPhone/iPod is using 24 hours in your clock settings, but, if you are using 12 hours format, it crashes and shows this error message
> *** Assertion failure in -[UIDatePickerView _updateBitsForDate:forced:andReload:animateIfNeeded:], /SourceCache/UIKit/UIKit-1914.85/UIDatePicker.m:1200 2012-06-29
> 01:19:15.753 MyApp[1215:707] *** Terminating app due to uncaught
> exception 'NSInternalInconsistencyException', reason: 'Invalid
> parameter not satisfying: date'
> *** First throw call stack: (0x3710188f 0x34e06259 0x37101789 0x379403a3 0x31042807 0x30f616c5 0x30f61563 0x31042385 0xf48ef 0xf7bd3
> 0x30e0ec8b 0x30e1b1e9 0x30e1b059 0x30e1af3f 0x30e1a7c1 0x30e1a503
> 0x30e0eaff 0x30e0e7d5 0xdd945 0x30e8793d 0x30f01627 0x37972933
> 0x370d5a33 0x370d5699 0x370d426f 0x370574a5 0x3705736d 0x33816439
> 0x30e03cd5 0xd4cbb 0xd4c60) terminate called throwing an
> exception(gdb)
So please, if you have any idea of how to fix this, I would appreciate your help
oh, and I've read that HH returns hours in 24 hours format, well, all my app uses HH, so i don't understand why I keep watching some "a.m." or "p.m." in some of the NSLogs i print to debug
Thanks in advance
oh sorry, I almost forget if i comment the lines
[datePicker setDate:startDate];
[timePicker setDate:startDate];
the app doesn't crash, but of course, it doesn't show the time and date I require
NOTE: I need to use 24 hours format, if I decide to select format with am pm I will have to change all my app, and well, I don't have enough time for that