2010-03-14 11 views
5

मैं एक तरह के कैलेंडर नियंत्रण बनाने हूँ में सप्ताह हो रही ...NSCalendar: समस्या एक महीने

एक बात मैं पता करने की जरूरत है कि कितने सप्ताह एक महीने में देखते हैं ...

तो NSCalendarrangeOfUnit:inUnit:forDate वास्तव में मैं क्या जरूरत होने के लिए ... लगता है

सिवाय मैं कुछ है कि बंद लगता है देख रहा हूँ और मैं काफी समझ नहीं क्यों यह हो रहा है ...

निम्नलिखित कोड ...

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]); 

} 

लौटने निम्नलिखित डीबग संदेश है ...

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 

मैं नहीं कर सकते यह समझ कारण है कि मैं महीने के 12.

कोई सुराग में 52 सप्ताह मिल सकता है?

3/20/2010 पर

संपादित करें:

कैसे मैं rangeOfUnit:inUnit:forDate का उपयोग एक महीने में सप्ताह की संख्या की गणना करने के लिए कर सके रूप में देखकर। मैंने एक ही मूल्य की गणना करने का एक अलग तरीका जानने का फैसला किया।

मुझे लगा कि मुझे इसे गैर-ग्रेगोरियन स्थानीय तरीके से करना चाहिए, इसलिए मैंने सप्ताह में दिनों की संख्या प्राप्त करने का प्रयास किया, लेकिन मुझे सप्ताह में 28 दिनों का परिणाम मिला। इसलिए मैंने यह जानने के लिए और कोड लिखना शुरू कर दिया कि क्यों ...

मैं यह सुनिश्चित करना चाहता था कि एनएससीएंडर का प्रकार जो मैं खेल रहा था वास्तव में मुझे क्या मिल रहा था ... और इससे मुझे कुछ मतभेद ...

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); 

और वह मुझे निम्नलिखित लॉग परिणाम मिल गया ...

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 

@ CarlNorum अनुभव से दिशा ले रहा है खोजने, मैं एक 10.6 कोको आवेदन के रूप में कोड स्निपेट संकलित, और मुझे निम्नलिखित मिल गया ...

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 

मुझे लगता है कि एक ग्रेगोरियन कैलेंडर के रूप में स्पष्ट रूप से एक NSCalendar उदाहरण बनाकर अपने मूल समस्या में बेहतर परिणाम के लिए नेतृत्व करेंगे ... में आशा देखा तो मुझे लगता है कि मूल कोड

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]); 

} 

संशोधित दुर्भाग्य से एक कैलेंडर बनाया का उपयोग कर इस तरह से एक अलग परिणाम नहीं लौटाया।

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 

बस के लिए kicks कोको के लिए कोड संकलन है, वास्तव में मनोरंजक था ... परिणाम के रूप में वास्तव में बहुत अलग

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 

मुझे लगता है कि यह तब होता है जब मैं हार रहे हैं ...

+0

मैंने अभी एक नई परियोजना बनाई और उस कोड को चलाया और यह अपेक्षा के अनुसार व्यवहार करता है। क्या आप सही कोड देख रहे हैं? –

+0

आपको दिसंबर में 52 सप्ताह मिल रहे हैं? –

+0

@AngrySpade, मुझे महीने 12 में '5 सप्ताह नहीं मिलते हैं। –

उत्तर

2

इस कोड को 10.6 एसडीके के साथ आजमाया और यह काम करता प्रतीत होता है।

 
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 

मैंने इसे आईफोन एसडीके के साथ करने की कोशिश की और मुझे वही आउटपुट मिलता है जो आप करते हैं। यह अस्पष्ट है कि आईफोन एसडीके कई अन्य महीनों के लिए भी सही मूल्यों का उत्पादन कर रहा है। मैं सहमत हूं, उदाहरण के लिए, 10.6 एसडीके जवाब के साथ जनवरी में 6 सप्ताह हैं।

मुझे आपके कोड के साथ स्पष्ट रूप से कुछ भी गलत नहीं दिख रहा है।

मैं पहले http://bugreport.apple.com पर जाकर और एक बग सबमिट करने का सुझाव दे सकता हूं।

आप ऐप्पल के निजी डेवलपर फ़ोरम (http://developer.apple.com/devforums/) पर भी जा सकते हैं और वहां पूछने का प्रयास कर सकते हैं।

बेशक, आप ऐप्पल ([email protected] - http://developer.apple.com/programs/adcbenefits/) में एक तकनीकी सहायता घटना भी सबमिट कर सकते हैं ... यदि आपके एडीसी खाते में कोई नहीं है, तो मेरा मानना ​​है कि ऐप्पल खुशी से आपको एक बेच देगा और आप इस मुद्दे के बारे में सीधे एक ऐप्पल इंजीनियर से बात कर सकते हैं।

+1

में एक विंडोज़ और वेब प्रोग्रामर होने से बहुत खुश हूं, मैंने मंच में पूछा ... हम देखेंगे कि इसमें कुछ भी आता है या नहीं। https://devforums.apple.com/thread/41850 –

+0

मुझे और पुष्टि मिली है कि यह एक बग है ... एक सेब बग सबमिट किया गया ... https://bugreport.apple.com/cgi-bin/ WebObjects/RadarWeb.woa/110/wo/bgn2sV1PSwrS42bBbWs2uM/10.79.28.0.9 –

+0

@AngrySpade: उस URL का उस सत्र के बाहर कुछ भी मतलब नहीं है। बग संख्या अधिक उपयोगी होगी। –

संबंधित मुद्दे