I'm on the road and not in front of a computer, so there's little I can do. However, I can say the code in NSCalendar is very dependent on ICU. Can you please provide some information on the version of GNUstep and ICU you are using? How did you install GNUstep? From source or package? Also, please verify that GNUstep is linked against ICU with the ldd command.
On Mar 1, 2015 8:47 AM, "Alessandro Sangiuliano" <
alex22_7@hotmail.com> wrote:
Il 01/03/2015 12:58, Alessandro Sangiuliano ha scritto:
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
I have to do an errata corrige.
I said that NSLogs are printing the correct output, and it is true for all NSLog except for:
NSLog(@"Numbers of Days %ld", monthDays);
monthDays = 31;
That NSLog prints the value of monthDays that is "0" for some reason (It should be 31, now that is March). Please, also, ignore the line
monthDays = 31
It was just for test and I forgot to delete it before sending the email.
Best regards,
Alex
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep