I calculate number of days between two dates:
NSDateComponents *datesDiff = [calendar components: NSDayCalendarUnit
fromDate: someDate
toDate: currentDate
options: 0];
But this method has one disadvantage – it doesn’t take in account time zone.
So, for example, if I’m in +2GMT and local time is 1:00AM, current date is yesterday.
How to compare dates in specified time zone (without ‘hacking’)?
PS: Preventing answers with calculation of time difference, I need difference of actual days:
yesterday 23:00vs.today 1:00–1 dayyesterday 1:00vs.today 23:00–1 day-
today 1:00vs.today 23:00–0 days -
(all this in current time zone)
I don’t know if it meets your criteria of not being hacky, but a fairly simple way seems to be defining a GMT adjusted date something like this:
See this question for more details.