Closed roxteddy closed 3 years ago
Hello @danielprrazevedo
I see no fix for this one. I was talking about the wheel itself, not the title.
I tried to set my device in French or English US and both in 12h and 24h mode (in device settings). The picker still appears in 24h.
Can you confirm you did any changes on this part please ?
Hey @roxteddy Can you send me a print of how your settings are on the device? Remembering that the behavior of is24 works as follows. If it is false or not set, it will ignore this setting and take the device default or the default defined in the language selected for the present call, if it is true, it will try to make it 24h. In that context, I received the expected behavior. Maybe this is something that I just couldn't reproduce, I would like to see how you are configuring the settings of the device, the picker and the result.
Ok my bad. I was playing with the wrong setting. So in device settings, the one affecting the wheel is "country" If I set it to "United States", picker is 12h format If I set it to "France', picker is 24h format
However, if we rely on device settings, it would be better to match this setting "Date & Time: 24-Hour Time enabled/disabled". I'm looking if it is possible to achieve that in swift code. Also, if we rely on our parameter "is24h", it would be better to also be able to force 12h mode. (For example, the user is in France but he swiched a 12h mode into the app.)
enum timeMode {
SYSTEM_DEFAULT,
12H,
24H
}
and display wheel and title accordingly
It may be a bit more tricky for datetime though..
Sorry, wrong again.
Wheel is affected by preferred language.
self.picker?.locale = Locale(identifier: Locale.preferredLanguages.first ?? "en")
I found an only way to play with time picker's format effectively. First of all, I don't think we should use UIDatePicker.Mode.countDown for that because it is designed for.. well, count down. So I found that, using Locale.current, wheel format will match the "24Hour Time" parameter from iOS settings. Or to force 12 or 24, we could manually choose language US or FR.
However, it won't work for dates because in the better case, it would use current country's language instead of preferred language. And in the worst case, the date we be in english or french despite the user's language. Not a big deal for date only because we can fall back using preferred language here. The problem will be with dateAndTime as there is now way to give different locales for both picker's parts
What we could do :
I don't need the last point for my app because we chose to pick date and time separately but it would be fair to give both options I probably need to force both 12 and 24h formats in the future to match our internal app's preferences.
WDYT @danielprrazevedo ? I'll let you see my branch with first changes once it is ready
Describe the bug Time wheel displays 24h format even with is24h false and device settings set to 24h mode : disabled
To Reproduce Steps to reproduce the behavior:
Expected behavior At least, display 12h mode when is24h is false or undefined
Better : display the proper wheel according to device settings
Screenshots
Smartphone (please complete the following information):