That's not a typo (at least not on my part, anyways.)
One of the defined NSCalendarUnits
are a NSCalendarCalendarUnit
. Can anyone explain what that is or how you would use it?
For example, I'd like to calculate the number of days between dates, which potentially took place in different eras. Apple provides this code for finding the number of days between dates within an era as such (it's implemented as a category on NSCalendar
, thus self
refers to an NSCalendar
):
NSInteger start = [self ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:startDate];
NSInteger end = [self ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:endDate];
return end - start;
Is the proper way of modifying this to accept the possibility of different eras by replacing NSEraCalendarUnit
with NSCalendarCalendarUnit
?