iphone - How to know if two NSDate are in the same day -


do know how know if 2 nsdate same day. want take account locale...

it easy use timeintervalsincedate: monday 23h58 , tuesday 00h01 not in same day...

dealing nsdate , locale calculation not easy.

nscalendar *calendar = [nscalendar currentcalendar];  nsdatecomponents *componentsforfirstdate = [calendar components:nsdaycalendarunit|nsmonthcalendarunit|nsyearcalendarunit fromdate:firstdate];  nsdatecomponents *componentsforseconddate = [calendar components:nsdaycalendarunit|nsmonthcalendarunit|nsyearcalendarunit fromdate:seconddate];  if ([componentsforfirstdate year] == [componentsforseconddate year]) 

etc.

i don't know if isequals want on nsdatecomponents.


Comments