ios - UIDatePicker strange behaviour with Islamic calendar -


note: bug reported apple

radar number: 29265429 (link)

i using uidatepicker. when give gregorian calendar works fine. days starts 1 31

however, when give islamic islamicummalqura gives me strange behaviour. days starts 1 30 there '2' above 1 , below 30 such days follows 2,1,2,3,4 ... 30

i have created new empty ios project , placed following code viewdidload method:

let picker = uidatepicker(frame: cgrect(x: 0, y: 30, width: 0, height: 0))  picker.datepickermode = .date picker.date = date() picker.calendar = calendar(identifier: .islamicummalqura) picker.autoresizingmask = uiviewautoresizing.flexiblerightmargin picker.frame.size.width = 300 view.addsubview(picker) 

screenshot:

enter image description here

it not hard make own uipicker looks uidatepicker, have careful because bug in nscalendar nsdatepicker.

just clear '2' not selectable, 30 not selectable in short month. nsdatepicker not hide invalid days or months, makes them unselectable. in gregorian calendar if select february still see 29, 30, , 31, trying select them picker got 28. datapicker figures out how many months , days show calling maximumrangeofunit: on calendar. in islamic calendar correct maximum {1, 30}, nscalendar returns {1,31} maximumrangeofunit:nscalendarunitday islamic calendars.

so there 2 bugs. 1 nscalendar saying there can 31 days in islamic month (which don't believe true), , second issue nsdatepicker showing 31st day 2 instead of 31.

making own nsdatepicker not hard. amount of element in each component same (just make sure manually set 30 days , not use value nscalendar). tricky part deciding if date invalid , showing element gray , not letting picket rest on it. can use rangeofunit:inunit:fordate number of days in month or number of months in year. if invalid element selected them move value down highest valid date (ie if user selects 30 in month 29 days select 29).

once row selected can convert day-month-year nsdate datefromcomponents on nscalendar.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -