NSCalendar *calendar = [NSCalendar currentCalendar];
NSRange range = [calendar rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:[NSDate date]];
NSUInteger numberOfDaysInMonth = range.length;
NSDate *datetime = [NSDate dateWithTimeIntervalSince1970:csmcurrentTime-(86400*numberOfDaysInMonth * data_current_index)];
NSDateFormatter *dateformat = [[[NSDateFormatter alloc] init] autorelease];
[dateformat setDateFormat:@"yyyy年MM月"];

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *comps = nil;

comps = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:mydate];

NSDateComponents *adcomps = [[NSDateComponents alloc] init];

[adcomps setYear:0];

[adcomps setMonth:-1];

[adcomps setDay:0];

NSDate *newdate = [calendar dateByAddingComponents:adcomps toDate:mydate options:0];

04-13 10:44