2010-03-14 10 views
5

Estoy creando un control de calendario de clases ...NSCalendar: Problema al obtener semanas en un mes

Una cosa que necesito saber es cuántas semanas hay en un mes ...

Así NSCalendarrangeOfUnit:inUnit:forDate parece ser exactamente lo que necesito ...

Excepto estoy notando algo que parece fuera y no puedo averiguar por qué esto está ocurriendo ...

El siguiente código ...

NSCalendar *calendar = [NSCalendar currentCalendar]; 

NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; 
[dateComponents setYear: 2010]; 
[dateComponents setDay: 1]; 

for (int x=1; x<=12; x++) 
{ 
    [dateComponents setMonth: x]; 

    NSDate *date = [calendar dateFromComponents:dateComponents]; 
    NSLog(@"Date: %@", date); 

    NSRange range = [calendar rangeOfUnit: NSWeekCalendarUnit 
            inUnit: NSMonthCalendarUnit 
            forDate:date]; 

    NSLog(@"%d Weeks in Month %d", range.length, [dateComponents month]); 

} 

está devolviendo los siguientes mensajes de depuración ...

2010-03-14 13:08:10.350 Scrap[4256:207] Date: 2010-01-01 00:00:00 -0500 
2010-03-14 13:08:10.351 Scrap[4256:207] 5 Weeks in Month 1 
2010-03-14 13:08:10.352 Scrap[4256:207] Date: 2010-02-01 00:00:00 -0500 
2010-03-14 13:08:10.352 Scrap[4256:207] 4 Weeks in Month 2 
2010-03-14 13:08:10.353 Scrap[4256:207] Date: 2010-03-01 00:00:00 -0500 
2010-03-14 13:08:10.353 Scrap[4256:207] 5 Weeks in Month 3 
2010-03-14 13:08:10.354 Scrap[4256:207] Date: 2010-04-01 00:00:00 -0400 
2010-03-14 13:08:10.355 Scrap[4256:207] 5 Weeks in Month 4 
2010-03-14 13:08:10.356 Scrap[4256:207] Date: 2010-05-01 00:00:00 -0400 
2010-03-14 13:08:10.357 Scrap[4256:207] 5 Weeks in Month 5 
2010-03-14 13:08:10.358 Scrap[4256:207] Date: 2010-06-01 00:00:00 -0400 
2010-03-14 13:08:10.358 Scrap[4256:207] 5 Weeks in Month 6 
2010-03-14 13:08:10.359 Scrap[4256:207] Date: 2010-07-01 00:00:00 -0400 
2010-03-14 13:08:10.360 Scrap[4256:207] 5 Weeks in Month 7 
2010-03-14 13:08:10.361 Scrap[4256:207] Date: 2010-08-01 00:00:00 -0400 
2010-03-14 13:08:10.364 Scrap[4256:207] 5 Weeks in Month 8 
2010-03-14 13:08:10.364 Scrap[4256:207] Date: 2010-09-01 00:00:00 -0400 
2010-03-14 13:08:10.365 Scrap[4256:207] 5 Weeks in Month 9 
2010-03-14 13:08:10.366 Scrap[4256:207] Date: 2010-10-01 00:00:00 -0400 
2010-03-14 13:08:10.366 Scrap[4256:207] 5 Weeks in Month 10 
2010-03-14 13:08:10.367 Scrap[4256:207] Date: 2010-11-01 00:00:00 -0400 
2010-03-14 13:08:10.367 Scrap[4256:207] 5 Weeks in Month 11 
2010-03-14 13:08:10.369 Scrap[4256:207] Date: 2010-12-01 00:00:00 -0500 
2010-03-14 13:08:10.369 Scrap[4256:207] 52 Weeks in Month 12 

I Cant averiguar por qué me sale 52 semanas en el mes 12.

Alguna pista?

Editar en 3/20/2010:

En vista de que no pude usar rangeOfUnit:inUnit:forDate para calcular el número de semanas en un mes. Decidí encontrar una forma diferente de calcular el mismo valor.

Pensé que debería hacer esto de una manera no gregoriana, por lo que intenté comenzar con la cantidad de días en una semana, pero obtuve el resultado de 28 días en una semana. Así que comencé a escribir más código para descubrir por qué ...

Quería asegurarme de que el tipo de NSCalendar con el que estaba jugando fuera en realidad lo que se suponía que debía obtener ... Y eso me llevó a encontrar algunas diferencias ...

NSCalendar *currentCalendar = [NSCalendar currentCalendar]; 

NSLog(@"Calendar with 'currentCalendar' Identifier: %@", 
     [currentCalendar calendarIdentifier]); 

NSCalendar *calendarWithIdentifier = [[[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar] autorelease]; 

NSLog(@"Calendar created with identifier Identifier: %@", 
     [calendarWithIdentifier calendarIdentifier]); 

NSDate *now = [[NSDate alloc] init]; 

NSDateComponents *currentMonth = [currentCalendar components: NSMonthCalendarUnit | NSYearCalendarUnit 
                fromDate: now]; 

NSDate *currentMonthDate = [currentCalendar dateFromComponents: currentMonth]; 

NSRange daysInWeekRange = [currentCalendar rangeOfUnit: NSDayCalendarUnit 
               inUnit: NSWeekCalendarUnit 
               forDate: currentMonthDate]; 

NSLog(@"CurrentCalendar: Length:%u Location:%u", daysInWeekRange.length, daysInWeekRange.location); 

currentMonth = [calendarWithIdentifier components: NSMonthCalendarUnit | NSYearCalendarUnit 
             fromDate: now]; 

currentMonthDate = [calendarWithIdentifier dateFromComponents: currentMonth]; 

daysInWeekRange = [calendarWithIdentifier rangeOfUnit: NSDayCalendarUnit 
               inUnit: NSWeekCalendarUnit 
               forDate: currentMonthDate]; 

NSLog(@"GregorianCalendar: Length:%u Location:%u", daysInWeekRange.length, daysInWeekRange.location); 

y eso me los siguientes resultados del registro tiene ...

2010-03-20 21:02:27.245 Scrap[52189:207] Calendar with 'currentCalendar' Identifier: gregorian 
2010-03-20 21:02:27.246 Scrap[52189:207] Calendar created with identifier Identifier: gregorian 
2010-03-20 21:02:27.248 Scrap[52189:207] CurrentCalendar: Length:28 Location:1 
2010-03-20 21:02:27.249 Scrap[52189:207] GregorianCalendar: Length:7 Location:1 

Tomar dirección de la experiencia de @ CarlNorum, compilé el fragmento de código como una aplicación Cocoa 10.6, y Obtuve lo siguiente ...

2010-03-20 21:05:35.636 ScrapCocoa[52238:a0f] Calendar with 'currentCalendar' Identifier: gregorian 
2010-03-20 21:05:35.636 ScrapCocoa[52238:a0f] Calendar created with identifier Identifier: gregorian 
2010-03-20 21:05:35.637 ScrapCocoa[52238:a0f] CurrentCalendar: Length:6 Location:1 
2010-03-20 21:05:35.638 ScrapCocoa[52238:a0f] GregorianCalendar: Length:7 Location:1 

vi esperanza en que la creación de una instancia NSCalendar explícitamente como un calendario gregoriano conduciría a mejores resultados en mi problema original ... Así que modifica el código original de

NSCalendar *currentCalendar = [NSCalendar currentCalendar]; 

NSLog(@"Calendar with 'currentCalendar' Identifier: %@", 
     [currentCalendar calendarIdentifier]); 

NSCalendar *calendarWithIdentifier = [[[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar] autorelease]; 

NSLog(@"Calendar created with identifier Identifier: %@", 
     [calendarWithIdentifier calendarIdentifier]); 

NSDateComponents *dateComponents = [[[NSDateComponents alloc] init] autorelease]; 
[dateComponents setYear: 2010]; 
[dateComponents setDay: 1]; 

for (int x=1; x<=12; x++) 
{ 
    [dateComponents setMonth: x]; 

    NSDate *date = [currentCalendar dateFromComponents: dateComponents]; 
    NSRange range = [currentCalendar rangeOfUnit: NSWeekCalendarUnit 
              inUnit: NSMonthCalendarUnit 
             forDate: date]; 

    NSLog(@"CurrentCalendar Date: %@", date); 
    NSLog(@"CurrentCalendar: %d Weeks in Month %d", range.length, [dateComponents month]); 

    date = [calendarWithIdentifier dateFromComponents: dateComponents]; 

    range = [calendarWithIdentifier rangeOfUnit: NSWeekCalendarUnit 
             inUnit: NSMonthCalendarUnit 
             forDate: date]; 

    NSLog(@"GregorianCalendar Date: %@", date); 
    NSLog(@"GregorianCalendar: %d Weeks in Month %d", range.length, [dateComponents month]); 

} 

Desafortunadamente el uso de un calendario creado de esa manera no devolvió un resultado diferente.

2010-03-20 21:15:40.465 Scrap[52367:207] Calendar with 'currentCalendar' Identifier: gregorian 
2010-03-20 21:15:40.466 Scrap[52367:207] Calendar created with identifier Identifier: gregorian 
2010-03-20 21:15:40.468 Scrap[52367:207] CurrentCalendar Date: 2010-01-01 00:00:00 -0500 
2010-03-20 21:15:40.468 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 1 
2010-03-20 21:15:40.469 Scrap[52367:207] GregorianCalendar Date: 2010-01-01 00:00:00 -0500 
2010-03-20 21:15:40.470 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 1 
2010-03-20 21:15:40.471 Scrap[52367:207] CurrentCalendar Date: 2010-02-01 00:00:00 -0500 
2010-03-20 21:15:40.471 Scrap[52367:207] CurrentCalendar: 4 Weeks in Month 2 
2010-03-20 21:15:40.472 Scrap[52367:207] GregorianCalendar Date: 2010-02-01 00:00:00 -0500 
2010-03-20 21:15:40.473 Scrap[52367:207] GregorianCalendar: 4 Weeks in Month 2 
2010-03-20 21:15:40.473 Scrap[52367:207] CurrentCalendar Date: 2010-03-01 00:00:00 -0500 
2010-03-20 21:15:40.474 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 3 
2010-03-20 21:15:40.475 Scrap[52367:207] GregorianCalendar Date: 2010-03-01 00:00:00 -0500 
2010-03-20 21:15:40.475 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 3 
2010-03-20 21:15:40.476 Scrap[52367:207] CurrentCalendar Date: 2010-04-01 00:00:00 -0400 
2010-03-20 21:15:40.477 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 4 
2010-03-20 21:15:40.478 Scrap[52367:207] GregorianCalendar Date: 2010-04-01 00:00:00 -0400 
2010-03-20 21:15:40.479 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 4 
2010-03-20 21:15:40.480 Scrap[52367:207] CurrentCalendar Date: 2010-05-01 00:00:00 -0400 
2010-03-20 21:15:40.480 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 5 
2010-03-20 21:15:40.482 Scrap[52367:207] GregorianCalendar Date: 2010-05-01 00:00:00 -0400 
2010-03-20 21:15:40.482 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 5 
2010-03-20 21:15:40.483 Scrap[52367:207] CurrentCalendar Date: 2010-06-01 00:00:00 -0400 
2010-03-20 21:15:40.483 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 6 
2010-03-20 21:15:40.484 Scrap[52367:207] GregorianCalendar Date: 2010-06-01 00:00:00 -0400 
2010-03-20 21:15:40.485 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 6 
2010-03-20 21:15:40.485 Scrap[52367:207] CurrentCalendar Date: 2010-07-01 00:00:00 -0400 
2010-03-20 21:15:40.486 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 7 
2010-03-20 21:15:40.486 Scrap[52367:207] GregorianCalendar Date: 2010-07-01 00:00:00 -0400 
2010-03-20 21:15:40.487 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 7 
2010-03-20 21:15:40.488 Scrap[52367:207] CurrentCalendar Date: 2010-08-01 00:00:00 -0400 
2010-03-20 21:15:40.488 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 8 
2010-03-20 21:15:40.489 Scrap[52367:207] GregorianCalendar Date: 2010-08-01 00:00:00 -0400 
2010-03-20 21:15:40.489 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 8 
2010-03-20 21:15:40.490 Scrap[52367:207] CurrentCalendar Date: 2010-09-01 00:00:00 -0400 
2010-03-20 21:15:40.491 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 9 
2010-03-20 21:15:40.491 Scrap[52367:207] GregorianCalendar Date: 2010-09-01 00:00:00 -0400 
2010-03-20 21:15:40.492 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 9 
2010-03-20 21:15:40.493 Scrap[52367:207] CurrentCalendar Date: 2010-10-01 00:00:00 -0400 
2010-03-20 21:15:40.493 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 10 
2010-03-20 21:15:40.494 Scrap[52367:207] GregorianCalendar Date: 2010-10-01 00:00:00 -0400 
2010-03-20 21:15:40.494 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 10 
2010-03-20 21:15:40.495 Scrap[52367:207] CurrentCalendar Date: 2010-11-01 00:00:00 -0400 
2010-03-20 21:15:40.496 Scrap[52367:207] CurrentCalendar: 5 Weeks in Month 11 
2010-03-20 21:15:40.496 Scrap[52367:207] GregorianCalendar Date: 2010-11-01 00:00:00 -0400 
2010-03-20 21:15:40.497 Scrap[52367:207] GregorianCalendar: 5 Weeks in Month 11 
2010-03-20 21:15:40.498 Scrap[52367:207] CurrentCalendar Date: 2010-12-01 00:00:00 -0500 
2010-03-20 21:15:40.498 Scrap[52367:207] CurrentCalendar: 52 Weeks in Month 12 
2010-03-20 21:15:40.499 Scrap[52367:207] GregorianCalendar Date: 2010-12-01 00:00:00 -0500 
2010-03-20 21:15:40.500 Scrap[52367:207] GregorianCalendar: 52 Weeks in Month 12 

Compilar el código de cacao, sólo por diversión, en realidad era divertido ... Como los resultados son realmente muy diferentes

2010-03-20 21:11:24.610 ScrapCocoa[52313:a0f] Calendar with 'currentCalendar' Identifier: gregorian 
2010-03-20 21:11:24.611 ScrapCocoa[52313:a0f] Calendar created with identifier Identifier: gregorian 
2010-03-20 21:11:24.613 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-01-01 00:00:00 -0500 
2010-03-20 21:11:24.613 ScrapCocoa[52313:a0f] CurrentCalendar: 6 Weeks in Month 1 
2010-03-20 21:11:24.614 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-01-01 00:00:00 -0500 
2010-03-20 21:11:24.615 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 1 
2010-03-20 21:11:24.616 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-02-01 00:00:00 -0500 
2010-03-20 21:11:24.616 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 2 
2010-03-20 21:11:24.617 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-02-01 00:00:00 -0500 
2010-03-20 21:11:24.618 ScrapCocoa[52313:a0f] GregorianCalendar: 4 Weeks in Month 2 
2010-03-20 21:11:24.619 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-03-01 00:00:00 -0500 
2010-03-20 21:11:24.619 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 3 
2010-03-20 21:11:24.620 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-03-01 00:00:00 -0500 
2010-03-20 21:11:24.621 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 3 
2010-03-20 21:11:24.622 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-04-01 00:00:00 -0400 
2010-03-20 21:11:24.622 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 4 
2010-03-20 21:11:24.623 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-04-01 00:00:00 -0400 
2010-03-20 21:11:24.623 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 4 
2010-03-20 21:11:24.624 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-05-01 00:00:00 -0400 
2010-03-20 21:11:24.625 ScrapCocoa[52313:a0f] CurrentCalendar: 6 Weeks in Month 5 
2010-03-20 21:11:24.625 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-05-01 00:00:00 -0400 
2010-03-20 21:11:24.626 ScrapCocoa[52313:a0f] GregorianCalendar: 6 Weeks in Month 5 
2010-03-20 21:11:24.627 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-06-01 00:00:00 -0400 
2010-03-20 21:11:24.627 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 6 
2010-03-20 21:11:24.628 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-06-01 00:00:00 -0400 
2010-03-20 21:11:24.628 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 6 
2010-03-20 21:11:24.629 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-07-01 00:00:00 -0400 
2010-03-20 21:11:24.630 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 7 
2010-03-20 21:11:24.630 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-07-01 00:00:00 -0400 
2010-03-20 21:11:24.631 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 7 
2010-03-20 21:11:24.632 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-08-01 00:00:00 -0400 
2010-03-20 21:11:24.632 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 8 
2010-03-20 21:11:24.633 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-08-01 00:00:00 -0400 
2010-03-20 21:11:24.633 ScrapCocoa[52313:a0f] GregorianCalendar: 6 Weeks in Month 8 
2010-03-20 21:11:24.634 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-09-01 00:00:00 -0400 
2010-03-20 21:11:24.635 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 9 
2010-03-20 21:11:24.636 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-09-01 00:00:00 -0400 
2010-03-20 21:11:24.636 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 9 
2010-03-20 21:11:24.637 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-10-01 00:00:00 -0400 
2010-03-20 21:11:24.637 ScrapCocoa[52313:a0f] CurrentCalendar: 6 Weeks in Month 10 
2010-03-20 21:11:24.638 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-10-01 00:00:00 -0400 
2010-03-20 21:11:24.639 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 10 
2010-03-20 21:11:24.640 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-11-01 00:00:00 -0400 
2010-03-20 21:11:24.640 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 11 
2010-03-20 21:11:24.641 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-11-01 00:00:00 -0400 
2010-03-20 21:11:24.641 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 11 
2010-03-20 21:11:24.642 ScrapCocoa[52313:a0f] CurrentCalendar Date: 2010-12-01 00:00:00 -0500 
2010-03-20 21:11:24.642 ScrapCocoa[52313:a0f] CurrentCalendar: 5 Weeks in Month 12 
2010-03-20 21:11:24.643 ScrapCocoa[52313:a0f] GregorianCalendar Date: 2010-12-01 00:00:00 -0500 
2010-03-20 21:11:24.644 ScrapCocoa[52313:a0f] GregorianCalendar: 5 Weeks in Month 12 

creo que esto es cuando me rindo ...

+0

Acabo de hacer un nuevo proyecto y ejecuté ese código y se comporta como se esperaba. ¿Es ese el código exacto que estás viendo fallido? –

+0

¿Obtendrá 52 semanas en diciembre? –

+0

@AngrySpade, no obtengo '5 semanas en el mes 12'. –

Respuesta

2

Intenté este código con el SDK 10.6 y parece que funciona.

 
2010-03-14 19:11:49.424 Untitled[61397:a0f] Date: 2010-01-01 00:00:00 -0500 
2010-03-14 19:11:49.425 Untitled[61397:a0f] 6 Weeks in Month 1 
2010-03-14 19:11:49.426 Untitled[61397:a0f] Date: 2010-02-01 00:00:00 -0500 
2010-03-14 19:11:49.427 Untitled[61397:a0f] 5 Weeks in Month 2 
2010-03-14 19:11:49.428 Untitled[61397:a0f] Date: 2010-03-01 00:00:00 -0500 
2010-03-14 19:11:49.429 Untitled[61397:a0f] 5 Weeks in Month 3 
2010-03-14 19:11:49.429 Untitled[61397:a0f] Date: 2010-04-01 00:00:00 -0400 
2010-03-14 19:11:49.430 Untitled[61397:a0f] 5 Weeks in Month 4 
2010-03-14 19:11:49.431 Untitled[61397:a0f] Date: 2010-05-01 00:00:00 -0400 
2010-03-14 19:11:49.431 Untitled[61397:a0f] 6 Weeks in Month 5 
2010-03-14 19:11:49.432 Untitled[61397:a0f] Date: 2010-06-01 00:00:00 -0400 
2010-03-14 19:11:49.433 Untitled[61397:a0f] 5 Weeks in Month 6 
2010-03-14 19:11:49.434 Untitled[61397:a0f] Date: 2010-07-01 00:00:00 -0400 
2010-03-14 19:11:49.434 Untitled[61397:a0f] 5 Weeks in Month 7 
2010-03-14 19:11:49.435 Untitled[61397:a0f] Date: 2010-08-01 00:00:00 -0400 
2010-03-14 19:11:49.436 Untitled[61397:a0f] 5 Weeks in Month 8 
2010-03-14 19:11:49.437 Untitled[61397:a0f] Date: 2010-09-01 00:00:00 -0400 
2010-03-14 19:11:49.437 Untitled[61397:a0f] 5 Weeks in Month 9 
2010-03-14 19:11:49.438 Untitled[61397:a0f] Date: 2010-10-01 00:00:00 -0400 
2010-03-14 19:11:49.439 Untitled[61397:a0f] 6 Weeks in Month 10 
2010-03-14 19:11:49.439 Untitled[61397:a0f] Date: 2010-11-01 00:00:00 -0400 
2010-03-14 19:11:49.440 Untitled[61397:a0f] 5 Weeks in Month 11 
2010-03-14 19:11:49.441 Untitled[61397:a0f] Date: 2010-12-01 00:00:00 -0500 
2010-03-14 19:11:49.441 Untitled[61397:a0f] 5 Weeks in Month 12 

Lo probé con el iPhone SDK y obtengo el mismo resultado que usted. No está claro si el SDK de iPhone está produciendo los valores correctos para muchos de los otros meses también. Estoy de acuerdo, por ejemplo, con la respuesta 10.6 SDK que Jan. tiene 6 semanas.

No veo nada obviamente mal con su código.

Podría sugerir en primer lugar dirigirse a http://bugreport.apple.com y enviar un error.

También puede dirigirse a los foros de desarrolladores privados de Apple (http://developer.apple.com/devforums/) e intentar preguntar allí.

Por supuesto, también puede enviar un incidente de soporte técnico a Apple ([email protected] - http://developer.apple.com/programs/adcbenefits/) ... si no tiene ninguno en su cuenta de ADC, creo que Apple estará encantado de venderle uno y puede hablar directamente con un ingeniero de Apple sobre este problema.

+1

que pregunté en el foro ... Veremos si surge algo. https://devforums.apple.com/thread/41850 –

+0

He recibido más confirmación de que este es un error ... Presenté un error de apple ... https://bugreport.apple.com/cgi-bin/ WebObjects/RadarWeb.woa/110/wo/bgn2sV1PSwrS42bBbWs2uM/10.79.28.0.9 –

+0

@AngrySpade: Esa URL no significa nada fuera de esa sesión. El número de error sería mucho más útil. –

Cuestiones relacionadas