Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error if iOS device preferred device language other than English #9

Open
mkelitz opened this issue Jan 21, 2019 · 3 comments
Open

Error if iOS device preferred device language other than English #9

mkelitz opened this issue Jan 21, 2019 · 3 comments

Comments

@mkelitz
Copy link

mkelitz commented Jan 21, 2019

Error if iOS device preferred device language other than English.

Easy t test, just switch language from device Settings > General > Language & Region > Make any other language first on Preferred Language order.

Date picker will report error "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value!" in CalendarHelper.swift "return date!" line 89

@mkelitz
Copy link
Author

mkelitz commented Jan 21, 2019

Changing BDate.swift getMonths() class to the following fixes the issue

class func getMonths() -> [String]{
//return ["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]
let formatter = DateFormatter()
let monthComponents = formatter.shortMonthSymbols
return monthComponents!
}

As it uses localised month short strings to visualise month in picker and uses same values to parse date from string in CalendarHelper.swift (let date = dateFormatter.date(from: "(currentMonth)/(currentDay)/(currentYear)"))

At least it works for me in Basque and Spanish

@mkelitz
Copy link
Author

mkelitz commented Jan 21, 2019

In addition to the fix, now the months are shown in the language used by the user in the device (and not only in English like before)

@AgileFlex
Copy link

Hello @mkelitz
The following fix will do the trick. Change the array to ["01", "02", "03"...."12"]. The date will still be recognizable & usable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants