views:

1265

answers:

1

Hello,

I'm sorry to make my first question here a bit of a simple one -- I've spent a day reading the NSLocale and NSCalendar class descriptions but I couldn't see if this was possible.

I have a UIDatePicker in the UIDatePickerModeDateAndTime mode. It is currently displaying date and time according to the user's locale, which is the default behavior.

I would like to be able to offer the option to show the UIDatePicker in either 12-hour or 24-hour time format. Detecting which time format the user is currently using isn't a problem, but I'm not clear on how to change just the time format of UIDatePicker without entirely throwing out the user's locale settings (since the picker also displays the localized days of the week and months). UIDatePicker supports setting its locale and setting its calendar.

So, question one is whether this is something I should be trying to do via NSLocale or NSCalendar, and question two is if anyone can recommend a way to isolate the time format without throwing out the rest of the user's locale settings.

Thanks for any suggestions.

+1  A: 

This is not the answer you are looking for, but in Cocoa you could create an NSDateFormatter and attach it to an NSDatePicker (which is an NSControl) using setFormatter. Unfortunately the equivalent iPhone class (UIControl) does not support this yet. I raised a bug with Apple about it and this is a known issue, although they wouldn't tell me if/when they plan to fix/enhance it.

Dan J