We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我在创建PGDatePicker时,设置了calendar和timeZone,但是在PGDatePicker+Common类的daysWithMonthInThisYear:withMonth:方法中,创建formatter后并未将calendar和timeZone设置进去。
} 如果系统的日历不是公历,比如是佛历,当传入的year为2020,month为2,date得到的结果是1477-02-09,再转换到range,得到2月份只有28天,比实际少了1天。如果对函数做如下修改:
} 可以解决问题,但是我不知道是否会对其他地方产生影响。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
我在创建PGDatePicker时,设置了calendar和timeZone,但是在PGDatePicker+Common类的daysWithMonthInThisYear:withMonth:方法中,创建formatter后并未将calendar和timeZone设置进去。
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM"];
NSString *dateStr = [NSString stringWithFormat:@"%ld-%ld",year,month];
NSDate *date = [formatter dateFromString:dateStr];
NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
NSRange range = [calendar rangeOfUnit:NSCalendarUnitDay
inUnit: NSCalendarUnitMonth
forDate:date];
return range.length;
}
如果系统的日历不是公历,比如是佛历,当传入的year为2020,month为2,date得到的结果是1477-02-09,再转换到range,得到2月份只有28天,比实际少了1天。如果对函数做如下修改:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.calendar = self.calendar;
formatter.timeZone = self.timeZone;
[formatter setDateFormat:@"yyyy-MM"];
NSString *dateStr = [NSString stringWithFormat:@"%ld-%ld",year,month];
NSDate *date = [formatter dateFromString:dateStr];
NSRange range = [self.calendar rangeOfUnit:NSCalendarUnitDay
inUnit: NSCalendarUnitMonth
forDate:date];
return range.length;
}
可以解决问题,但是我不知道是否会对其他地方产生影响。
The text was updated successfully, but these errors were encountered: