It's clear how can I calculate the time between two exact date, but I would like to know the date between the actual date and the next monday 2:00 PM.
As an instance, users can reserve places for yoga classes, there is a class that starts on every monday 2:00 PM. So how can I calculate the date of next monday compared to [NSDate date]
? I would like to display the remaining time until the next class.
// Date of the next class - how can i get this date?
// NSDate *nextCourse = [NSDate ??];
NSCalendar *deviceCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *date2 = [[NSDate alloc] initWithTimeInterval:nextCourse sinceDate:date1];
unsigned int unitFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *conversionInfo = [deviceCalendar components:unitFlags fromDate:date1 toDate:date2 options:0];