Calculates the number of days between a date and the current date.
// Returns the day 0, Day 1, Day 2, and so on.
// The time difference is used to divide the number of seconds of a day, and the calculated number of days has an error.
+ (Int) getDaysFromAnotherDay :( longlong) date {// date is the timestamp
// Return [self getDaysFrom1970: date]-[self getDaysFrom1970: [NSDate date] timeIntervalSince1970];
NSDateComponents * comps = [[NSDateComponentsalloc] init];
[CompssetDay: [NSDateUtilsgetDay: date];
[CompssetMonth: [NSDateUtilsgetMonth: date];
[CompssetYear: [NSDateUtilsgetYear: date];
NSCalendar * gregorian = [[NSCalendaralloc] initWithCalendarIdentifier: NSGregorianCalendar];
NSDate * endDate = [[NSDatealloc] init];
NSDate * startDate = [gregoriandateFromComponents: comps];
[Compsrelease];
Unsignedint unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents * comps2 = [gregoriancomponents: unitFlags fromDate: startDatetoDate: endDate options: 0];
Int days = [comps2day];
Return days;
}
+ (Int) getYear :( longlong) date {
Return [[selfgetNSDateComponents: date] year];
}
+ (Int) getMonth :( longlong) date {
Return [[selfgetNSDateComponents: date] month];
}
+ (Int) getDay :( longlong) date {
Return [[selfgetNSDateComponents: date] day];
}
+ (NSDateComponents *) getNSDateComponents :( longlong) date {
NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents * comps = [[selfshareNSCalendar] components: unitFlags fromDate: [NSDatedateWithTimeIntervalSince1970: date];
Return comps;
}