Can I have UIDatePicker pick dates earlier than 01/01/0001 AD/CE?

79 Views Asked by At

Is there any way to select negative years? (i.e. years in the BC era)

I am only able to scroll the year column to minimum of "1". However, I wish to allow selecting BC years, such as -100, -1000, etc.

Is this possible with the UIDatePicker?

I tried to set the minimumDate property of UIDatePicker to a negative year, but that didn't affect the UI of the date picker control. Following is my code:

NSDateComponents *components = [[NSDateComponents alloc] init];
[components setYear:-2000];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDate *minDate = [gregorian dateFromComponents:components];

components = [[NSDateComponents alloc] init];
[components setYear:2000];
NSDate *maxDate = [gregorian dateFromComponents:components];

self.datePicker.minimumDate = minDate;
self.datePicker.maximumDate = maxDate;

And here is the result, where I still can't select any year before "1":

enter image description here

Any ideas?

0

There are 0 best solutions below