How to Display UIDatePicker Dates in Hindi with English Numbers/Digits - ios

I want to display date in date pickers in Hindi language but the digits in English.
example
I was able to get the screenshot by setting the language of the device to Hindi and digits to English.
But I want to achieve it programatically.
I tried:
UIDatePicker *datePicker;
[datePicker setLocale:[[NSLocale alloc] initWithLocaleIdentifier:#“hi”]];
//or #“hi_IN”
but what I get is this
So, how can I set the digits to be in English?

Related

islamicUmmAlQura UIDatePicker is not working properly

I am using islamicUmmAlQura UIDatePicker while developing iOS application as shown in the following
picture
and I have TWO problems summarised as follows:
1- The date that appears in the text field is gregorian while my UIDatePicker is islamic (Hijri) see figure
2- Sometimes the days in the Textfields are above normal! see figure
I have an extension on github to convert dates. Have a look. mine is persian date so you just need to replace the below code with mine inside the extension:
datePicker.calendar = Calendar(identifier: .islamicUmmAlQura)
[https://github.com/Fridday/PersianDatePicker][1]

How to DatePicker with Year Month day time

How to get DatePicker |Year|Day Date Month|Time Min|Second|AM PM| ?
Default DatePicker Showing its showing |Day Date Month | Min | Seconds|
Date picker is a very high level component and does not allow explicit setting of display in any way. There are properties you can play around with such as datePickerMode and locale. For your case I guess you should find a correct locale.
This is not advised though. The thing is that locale is set automatically or it should be set to whatever makes sense to user which world-wide depends on the user. If you override this functionality you will most likely confuse users.
Anyway if you can't get the result you want with date picker you will have to user a normal picker view and manage sections and rows yourself.
You can get some how close to your desired requirement by setting DatePicker's datePickerMode property
myDatePicker.datePickerMode = .dateAndTime
see the more available datepicker mode .here
UIDatePicker takes device Time format. If you have 24 hour Date format selected in your device, the UIDatePicker will not show AM/PM and show the time in 24hr. format. So you have to change the Time format of the device to 12 hour format. We can not set the time format of the UIDatePicker.

Changing locale of UIDatePicker in Countdown Timer mode

I have UIDatePicker in CountdownTimer mode and need to change the wording of hours and min to German locale. I tried both, to set locale to German (Germany) in storyboard and in code, but both failed and the app still shows default english words for hours and min.
timePicker.locale = Locale(identifier: "de")
When I configure locale on UIDatePicker in Date and Time mode, it correctly respects German locale and displays the date in german format. Any idea why locale does not change in Countdown timer mode? Thank you.
Thanks to Why UIActivityViewController doesn't display localized cancel string? post the solution also resolved the issue of localizing UIDatePicker in countdown timer mode, at least on iOS 11. Thank you.
Add this row into your info.plist:
And it also helps to correctly localize Cancel button of the system share sheet: UIActivityViewController - how to change the cancel button text.
I am mentioning here reply from APPLE that i got upon Technical support on this specific issue but unfortunately there is no support to this feature yet.
When running in the count down mode, UIDatePicker showns the hours and minutes to count down. In this context, the “hours” and “minutes” are not a format, thus not covered by locale;
Thing is that they did not mention any time line for support of this feature.

How to have this date picker mode?

The reminders app uses this date picker mode of "wed, april 20" and the hours, but in my app, I'd like to have only the "wed, april 20" format. I'm using the normal Date mode (date - month - year) right now, but as it is not showing the date's name its a bit confusing. Is this a normal mode that I can use (the reminders app mode)?
Taking the flow of the question, I also wanna ask something: to set the date picker as a text field's input view I need to create an action of the text field and use textField.inputView = datePicker
Right?
Reply to the questions you know, or both, thanks in advance!
The date format of the UIDatePicker can only be set using it's mode property and it doesn't allow a lot of flexibility, like displaying a week day. If you want to achieve this you either have to make your own date picker using a UIPickerView, or find some of the third-party components available online.
You can change datePicker mode as
[picker setDatePickerMode:UIDatePickerModeDateAndTime];

How to modify UIDatePicker to get rid of era being shown?

When I set UIDatePickder calendar type to Arabic calendar like below
NSCalendar *hijriQamariCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSIslamicCivilCalendar];
[self.resultCalendarOutlet setCalendar:hijriQamariCalendar];
I get era also displayed in the UIDatePikcer. I am looking for a way to either have the era removed from the UIDatePicker from being displayed or customize its value/text.
UIDatePicker with Arabic Calendar showing era:
Please see the given images. I am not sure if this is possible first. However, UIDatePicker for Gregorian calendar doesn't display any era information.
UIDatePicker with Gregorian Calendar - No era :
which is fine for me.

Resources