标签:
很奇怪,它是根据前8个月中奇数月为31天,偶数月为30天,和后4个月,奇数月为30天,偶数数为31天,来进行编码的。
代码:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSLog(@"8月的天数%ld",(long)[self getCurrentDay:8]); } //获得当前的月的天数 -(NSInteger )getCurrentDay:(int) currentMonth{ if (currentMonth < 8 ) { if (currentMonth %2 ==1) { return 31; }else{ return 30; } }else{ if (currentMonth %2 ==1) { return 30; }else{ return 31; } } }
输出:
2015-03-11 14:29:06.259 获得当前的月的天数[3206:145520] 8月的天数31
标签:
原文地址:http://www.cnblogs.com/yang-guang-girl/p/4329831.html