NYDateTimePicker icon indicating copy to clipboard operation
NYDateTimePicker copied to clipboard

2月超过28/29天解决方法

Open qiangzai opened this issue 7 years ago • 0 comments

在 -(void)changeDateLabel 里添加

    NSInteger day = self.selectedComponents.day;
    NSInteger month = self.selectedComponents.month;
    NSInteger year = self.selectedComponents.year;
    
    if (month == 2 && day > 28) {
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            day = 29;
            [self.selectedComponents setDay:day];
        } else {
            day = 28;
            [self.selectedComponents setDay:day];
        }
    }

qiangzai avatar Apr 27 '17 08:04 qiangzai