WenchaoD / FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift
MIT License
10.6k stars 1.94k forks source link

about "today" bug #1161

Open FunnyerFeng opened 4 years ago

FunnyerFeng commented 4 years ago

Do not exit APP,Lock screen let it stand for a day and then unlock it . because: _today = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:[NSDate date] options:0]; so "today" is Still the day of the lock screen.

darkengine commented 4 years ago

Agree, we met the same problem. When the App stand more than one day. The gray shadow for "today" is mark in wrong day.

darkengine commented 4 years ago

Do not exit APP,Lock screen let it stand for a day and then unlock it . because: _today = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:[NSDate date] options:0]; so "today" is Still the day of the lock screen.

I find the solution: observe NSCalendarDayChangedNotification event. This will be called when day change, then call setToday to update FSCalendar.

kleber-maia commented 4 years ago

Is anyone creating a PR to fix this issue?

Additionally, the following line should not be inside setToday method:

FSCalendarAssertDateInBounds(today,self.gregorian,self.minimumDate,self.maximumDate);

In my case, I'm setting calendar minimumDate, maxinumDate properties, however those properties have nothing to do with circling "Today" correctly on the calendar.

Consider the following example, in which minimumDate is set to Jun/12 and today is Jun/11. In this specific case, because today property was set during initialization, minimumDate was still not set, hence it works as expected. But if you set today property to Jun/11 anytime after initialization, an exception will be thrown, while the expected result is that NO exception should happen.

image