About
The place where shares everything about mobile technology!
+ (NSDate *)createCustomDateFromDay:(NSInteger)_day month:(NSInteger)_month year:(NSInteger)_year
{
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setDay:_day];
[comps setMonth:_month];
[comps setYear:_year];
NSDate *date = [[gregorian dateFromComponents:[comps autorelease]] autorelease];
return date;
}
+ (void)currentDay:(int *)_day month:(int *)_month year:(int *)_year
{
NSDate *curentDate = [NSDate date];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* compoNents = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit fromDate:curentDate]; // Get necessary date components
compoNents = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit|NSDayCalendarUnit fromDate:curentDate];
*_month = [compoNents month];
*_day = [compoNents day];
*_year = [compoNents year];
}
int day = 0, month = 0, year = 0;
[Utilities currentDay:&day month:&month year:&year];
NSLog(@"%d %d %d", day, month, year);
[Utilities createCustomDateFromDay:day+1 month:month+1 year:year];