के रूप में सभी अमेरिकी छुट्टियों की सूची मैं सभी अमेरिकी छुट्टियों को NSDate
एस के रूप में प्राप्त करने का एक तरीका ढूंढ रहा हूं। क्या इसे लागू करने का कोई तरीका है?एनएसडीएटी
6
A
उत्तर
2
- Here आपको छुट्टियों के साथ आरएसएस-फीड्स मिलेंगे। यह वर्ष सूचीबद्ध नहीं करता है, लेकिन दस्तावेज़ों में आपको जानकारी मिल जाएगी कि दिनांक सीमाएं कैसे बदलें।
- इसे डाउनलोड करें। मैं उस कार्य के लिए ASIHTTPRequest का सुझाव दूंगा।
आरएसएस फ़ीड को पार्स करें। आप सामान्य एक्सएमएल-पार्सिंग द्वारा ऐसा कर सकते हैं, या आप एक विशेष पार्सर का उपयोग करते हैं। MWFeedParser एक विकल्प होगा। - तिथियां सहेजें। या तो कोरडाटा, या Event Kit Framework
5
यदि आप केवल यूएस संघीय छुट्टियां चाहते हैं, तो मैंने यह विधि लिखी है। हालांकि आप इन तकनीकों का उपयोग किसी भी छुट्टी की गणना के लिए कर सकते हैं।
-(NSArray *)getUSHolidyas{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy";
NSString *year = [formatter stringFromDate:[NSDate date]];
formatter.dateFormat = @"M/d/yyyy";
//Constant Holidays
NSDate *newYearsDay = [formatter dateFromString:[NSString stringWithFormat:@"1/1/%@",year]]; //Use next year for the case where we are adding days near end of december.
NSDate *indDay = [formatter dateFromString:[NSString stringWithFormat:@"7/4/%@",year]];
NSDate *vetDay = [formatter dateFromString:[NSString stringWithFormat:@"11/11/%@",year]];
NSDate *xmasDay = [formatter dateFromString:[NSString stringWithFormat:@"12/25/%@",year]];
//Variable Holidays
NSInteger currentYearInt = [[[NSCalendar currentCalendar]
components:NSYearCalendarUnit fromDate:[NSDate date]] year];
NSDate *mlkDay = [self getTheNth:3 occurrenceOfDay:2 inMonth:1 forYear:currentYearInt];
NSDate *presDay = [self getTheNth:3 occurrenceOfDay:2 inMonth:2 forYear:currentYearInt];
NSDate *memDay = [self getTheNth:5 occurrenceOfDay:2 inMonth:5 forYear:currentYearInt]; // Let's see if there are 5 Mondays in May
NSInteger month = [[[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:memDay] month];
if (month > 5) { //Check that we are still in May
memDay = [self getTheNth:4 occurrenceOfDay:2 inMonth:5 forYear:currentYearInt];
}
NSDate *labDay = [self getTheNth:1 occurrenceOfDay:2 inMonth:9 forYear:currentYearInt];
NSDate *colDay = [self getTheNth:2 occurrenceOfDay:2 inMonth:10 forYear:currentYearInt];
NSDate *thanksDay = [self getTheNth:4 occurrenceOfDay:5 inMonth:11 forYear:currentYearInt];
return @[newYearsDay,mlkDay,presDay,memDay,indDay,labDay,colDay,vetDay,thanksDay,xmasDay];
}
-(NSDate *)getTheNth:(NSInteger)n occurrenceOfDay:(NSInteger)day inMonth:(NSInteger)month forYear:(NSInteger)year{
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.year = year;
dateComponents.month = month;
dateComponents.weekday = day; // sunday is 1, monday is 2, ...
dateComponents.weekdayOrdinal = n; // this means, the first of whatever weekday you specified
return [[NSCalendar currentCalendar] dateFromComponents:dateComponents];
}
संबंधित मुद्दे
- 1. एनएसडीएटी कॉम्पोनेंट्स से एनएसडीएटी
- 2. एनएसडीएटी
- 3. एनएसडीएटी
- 4. एनएसडीएटी की तुलना [एनएसडीएटी तिथि]
- 5. एनएसडीएटी मूल्य
- 6. एनएसडीएटी ऑब्जेक्ट
- 7. एनएसडीएटी: समय
- 8. दो एनएसडीएटी
- 9. आईएसडी एसडीके एनएसएसटींग एनएसडीएटी
- 10. एनएसडीएटी एनएसएसटींग एन्कोडिंग
- 11. दो दिए गए एनएसडीएटी
- 12. अपने एनएसडीएटी गुणों
- 13. यदि एनएसडीएटी सोमवार
- 14. आईओएस - दोस्ताना एनएसडीएटी प्रारूप
- 15. एनएसडीएटी कोई समय तत्व
- 16. एनएसडीएटी से दिन का नाम?
- 17. एनएसडीएटी को मिलीसेकंड्स युग टाइम
- 18. एनएसडीएटी डेट ऑब्जेक्ट कैसे बनाएं?
- 19. एनएसडीएटी कारणों के साथ एनएसपीडिकेट - [__ एनएसडीएटी निरंतर वैल्यू]: अज्ञात चयनकर्ता उदाहरण 0x1e7ff0
- 20. एनएसडीएटी से घंटों को कैसे घटाता है?
- 21. कल एनएसडीएटी के उद्देश्य से सी
- 22. कोको में एनएसडीएटी में एनएसटीइम इंटरवल जोड़ें
- 23. एनएसडीएटी पर समय कैसे सेट करें? मिनट:
- 24. एनएसएसटींग को एनएसडीएटी में कैसे चालू करें?
- 25. एनएसडीएटी के कुछ घटकों की तुलना करना?
- 26. यह जांचना कि क्या एक एनएसडीएटी
- 27. उसी तारीख/समय के लिए दो एनएसडीएटी की तुलना करें
- 28. कैसे पता चलेगा कि दो एनएसडीएटी उसी दिन हैं
- 29. मैं कल के एनएसडीएटी को कैसे प्राप्त कर सकता हूं
- 30. कोर डेटा सेव त्रुटि (NSValidationErrorKey, कोको त्रुटि 1570) एनएसडीएटी
एफवाईआई, आरएसएस फ़ीड लिंक अब कहा गया है (1 9 फरवरी, 2015 तक)। –