discuss-gnustep
[Top][All Lists]
Advanced

[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 14:47:48 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0

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




reply via email to

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