Skip to content
New issue

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

Today date does not update after changing device date #600

Closed
h-bomb opened this issue Feb 27, 2017 · 6 comments
Closed

Today date does not update after changing device date #600

h-bomb opened this issue Feb 27, 2017 · 6 comments

Comments

@h-bomb
Copy link

h-bomb commented Feb 27, 2017

If you change the device's date then return to the calendar, today (day color and/or selection) does not update.

Device(s): All
FSCalendar version: current (v2.7.2) / master branch
Occurs in sample project: Yes
Xcode version: 8.2.1

Steps to reproduce:

  1. Launch the v2.7.2 Swift sample app.
  2. Select any calendar project that shows today and note the selected / color of today.
  3. Place the app in the background, go to Settings > General > Date & Time, toggle Set Automatically to off and change the date to a different date.
  4. Return to the Swift sample app.

Result:

The calendar does not update today's date (selection or color).

Expected:

The calendar should always reflect the correct date for today. If today was selected before putting the app in background, the correct today day should be selected and today color updated. If a different date was selected before putting the app in the background, only the today day color should be updated (the last selected date should still be selected, but the selection color should be the non-today color.)

@h-bomb h-bomb changed the title Today date does not update after changing device time Today date does not update after changing device date Feb 27, 2017
h-bomb pushed a commit to h-bomb/FSCalendar that referenced this issue Feb 27, 2017
h-bomb pushed a commit to h-bomb/FSCalendar that referenced this issue Feb 27, 2017
h-bomb pushed a commit to h-bomb/FSCalendar that referenced this issue Feb 28, 2017
Reverted setToday and created new method based on setToday to fix:
WenchaoD#600
@WenchaoD
Copy link
Owner

Hi @h-bomb
Thanks for reporting this. A workaround for updating is to register notification observer for NSCalendarDayChangedNotification or UIApplicationSignificantTimeChangeNotification and call self.calendar.today = ... on receiving the notification.

@h-bomb
Copy link
Author

h-bomb commented Feb 28, 2017

Hi @WenchaoD - yes, that is what I did in my controller, but had an issue with setToday in the forked branch I've been working on:

if (![self.gregorian isDateInToday:today]) {

needed to change to (note the removal of the logical not (!)) to:

if ([self.gregorian isDateInToday:today]) {

Now I'm currently having a mysterious issue with our release build vs. our debug build - when running the release build, after changing the date and returning to the app, all of the days get highlighted with the today color. This doesn't occur in the debug build, though. Have you ever seen anything like this? Trying to debug now...

@h-bomb h-bomb closed this as completed Feb 28, 2017
@h-bomb h-bomb reopened this Feb 28, 2017
@h-bomb
Copy link
Author

h-bomb commented Feb 28, 2017

(Sorry for the accidental close / re-open @WenchaoD.)

I confirmed that the release build issue I mentioned above does occur in your latest Swift sample app.

Steps to reproduce:

  1. In of the view controllers (in my case I used FSCalendarScopeExampleViewController), in viewDidLoad, add the following:

NotificationCenter.default.addObserver(self, selector: #selector(systemTimeChanged), name: NSNotification.Name.UIApplicationSignificantTimeChange, object: nil)

  1. Add the method:
@objc fileprivate func systemTimeChanged() {
     calendar.today = Date()
}
  1. Under the active scheme drop-down, select to Edit Scheme... and under Run, for Build Configuration, select Release and Close the dialogue. (Note that you will likely want to revert this setting later.)

  2. Under the device drop-down, select a device to build and deploy to. You'll want to use a device so that you can make the date change while the app is in the background.

  3. Build and deploy the app.

  4. Select the FSCalenderScope project and note the selected / color of today (Should be blue).

  5. Place the app in the background, go to Settings > General > Date & Time, toggle Set Automatically to off and change the date to a different date.

  6. Return to the Swift sample app.

Result

The current date is selected with a blue selection circle, but all of the other days are selected with a red selection circle:

fscalendar-date-change-issue

Expected

The current date should selected with a blue selection circle and all of the other days should not have a selection circle around them.

Note: If you swipe to another month and swipe back, the issue resolves itself.

@h-bomb
Copy link
Author

h-bomb commented Mar 2, 2017

@WenchaoD - I believe I have a solution to the second issue above. After our QA team confirms the fix, I'll post my solution.

h-bomb pushed a commit to h-bomb/FSCalendar that referenced this issue Mar 2, 2017
…Release build only)

Fix for all calendar days set as today title color in current month
(Release build only) - second issue reported in:
WenchaoD#600
@h-bomb
Copy link
Author

h-bomb commented Mar 3, 2017

@WenchaoD - the solution in the commit above fixed the Release build issue.

WenchaoD pushed a commit that referenced this issue Mar 3, 2017
@WenchaoD
Copy link
Owner

WenchaoD commented Mar 3, 2017

I see. I've found a simpler solution. It works for me.

@WenchaoD WenchaoD closed this as completed Mar 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants