I have a code similar to this:
let datePicker = NSDatePicker(....)
self.addSubview(datePicker)
self.window?.makeFirstResponder(datePicker)
When makeFirstResponder is called first element gets editing focus. For U.S region this picks day of the month, because date format is DD-MM-YYYY. For other regions when date format is YYYY-MM-DD, YYYY gets editing focus. How can I force NSDatePicker to start editing day of the month no matter what date format is?
You can use DateFormatter method
func dateFormat(fromTemplate tmplate: String, options opts: Int, locale: Locale?) -> String?to check the current locale dateFormat, check the location of the day and send the tab key 0, 1 or 2 times: