Il 01/03/2015 11:06, Riccardo Mottola ha scritto:
Hi,
Alessandro Sangiuliano wrote:
NSRange range = [gregorian rangeOfUnit:NSDayCalendarUnit
inUnit:NSMonthCalendarUnit forDate: [gregorian
dateFromComponents:components]];
monthDays = range.length;
NSLog(@"Numbers of Days %ld", monthDays);
From the NSLog I can see that monthDays is "0", insted on OS X is
28 (for february, 31 for Jan, and so on). What I wrong?
Have you checked out the components? e.g. is "gregorian" valid?
components?
Can you split this code up in a small example that can be run from
the command line? so I can compare how it works on 10.6 and 10.4 for
example and see if it works on GNUstep, debug, etc etc.
Riccardo
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
Ok, when I'll have the time I'll write a little tool to test:
1) NSCalendar initialization
2) NSDateComponents creation from NSCalendar
3) Some other things similar to the previous
4) If you have requests, add them...
In the while I added this code to that method:
- (void)
setMonthDaysMonthAndYearFromComponents:(NSDateComponents*)components
{
[monthLabel setStringValue:[monthSymbols
objectAtIndex:[components month] - 1]];
[yearLabel setStringValue:[NSString stringWithFormat:@"%ld",
[components year]]];
NSLog(@"Components verification:\nday %ld\nmonth %ld\nyear
%ld.\n Calendar verification %@", [components day], [components
month], [components year], [gregorian description]);
NSDate *tmp = [gregorian
dateFromComponents:components];
NSLog(@"Date from components
verification: %@", [tmp description]);
NSRange range = [gregorian rangeOfUnit:NSDayCalendarUnit
inUnit:NSMonthCalendarUnit forDate:[gregorian
dateFromComponents:components]];
monthDays = range.length;
NSLog(@"Numbers of Days %ld", monthDays);
monthDays = 31;
}
All the NSLog are printing the correct output, so it is all valid.
Also, the xcodeproj file on gitub, in the Calendar root directory was
generated by Xcode 3.2.2 from OS X 10.6.8
Alex.
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep