[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: NSCalendar behavior

From: Alessandro Sangiuliano
Subject: Re: Fwd: NSCalendar behavior
Date: Sun, 1 Mar 2015 12:58:43 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0

Il 01/03/2015 11:06, Riccardo Mottola ha scritto:

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.


Discuss-gnustep mailing list

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]