Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am nickplace on github.
* I am nickplace (https://keybase.io/nickplace) on keybase.
* I have a public key ASCKbqDliCJ-p9lqzohBD3o7Re075FZujF76SzE-K1MKOAo
To claim this, I am signing this object:
@nickplace
nickplace / gist:8242890
Created January 3, 2014 17:59
#Find the number of midnights between two dates Apple's prescribed way of getting the number of days between two days (using dateComponents) was being very unreliable for me so I had to come up with my own solution for finding the number of midnights between two dates.
NSDate startDate = ...;
NSDate endDate = ...;
NSTimeInterval startDays = ceil( [startDate timeIntervalSince1970] / 86400); // there are 86400 seconds in a day
NSTimeInterval endDays = ceil ( [endDate timeIntervalSince1970] / 86400);
int days = endDays - startDays;