Skip to content

Instantly share code, notes, and snippets.

@jorjeb
jorjeb / gist:1408705aaa77963a9e69
Last active August 29, 2015 14:19
NSDate: Getting the time at start of day
+ (NSDate *)withTimeAtStartOfDay:(NSDate *)date
{
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *components = [cal components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:date];
[components setHour:0];
[components setMinute:0];
[components setSecond:0];
return [cal dateFromComponents:components];

Keybase proof

I hereby claim:

  • I am jorjeb on github.
  • I am jorjeb (https://keybase.io/jorjeb) on keybase.
  • I have a public key whose fingerprint is F620 3219 BEAC 07FD 9E30 7CFF 3E7D 98AA 3953 FEDB

To claim this, I am signing this object: