I'm trying to do something that is a little difficult for me. But I'm sure someone has an understanding.
Given the date, let's say January 17, 2011I'm trying to figure out the day corresponding to that date a year ago. So, it January 17, 2011’s Monday, and a year ago this day fell on January 18, 2010(Monday too). It turns out that January 18, 2010is 354 days before January 17, 2011. Initially, I thought just to subtract 365 days for a non-leap year and 366 days for a leap year, but if you do this in this case, you will get January 17, 2010it Sunday, not Monday.
So, in Objective-C with NSDateand NSCalendar, how could I implement a function like:
-(NSDate *)logicalOneYearAgo:(NSDate *)from {
}
In other words, the nth “working day” in the nth month (where “weekday” is Monday or Tuesday or Wednesday, etc.)
source
share