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

Can't change calendar today date #514

Closed
kallahir opened this issue Dec 15, 2016 · 5 comments
Closed

Can't change calendar today date #514

kallahir opened this issue Dec 15, 2016 · 5 comments

Comments

@kallahir
Copy link
Contributor

kallahir commented Dec 15, 2016

Hi,

I'm trying to change the today date using the NSCalendarDayChanged notification, but I'm not being able to do so. Does anyone knows how to do it?

Edit: I tried changing the date by setting:

self.calendar.today = Date()

When I set today like in the code above, the date value doesn't change but if I click in the day that I tried to set as the new today in the calendar the day gets marked as today and I get two todays at the same time, but if I navigate trough the calendar than gets back to the place where I had the "todays" the one that should be the right is gone and the old one is still there.

And by posting the notification that I found in some issues:

NotificationCenter.default.post(name: Notification.Name.UIApplicationSignificantTimeChange, object: nil)

But none of those worked.

Best regards.

@kallahir kallahir changed the title Canot Can't change calendar today date Dec 15, 2016
WenchaoD added a commit that referenced this issue Dec 15, 2016
@WenchaoD
Copy link
Owner

Seems working well under this commit

@kallahir
Copy link
Contributor Author

WenchaoD, thanks for such a quick answer!

I updated the piece of code and it worked, the circle moved perfectly, but I noticed that the today date hasn't effectively changed because when I move from one page than I get back to the page with the today mark it gets back to the old date, like in the video below:

today_gif-2

So I went through the code and replaced this piece of code:

    if (![self.gregorian isDateInToday:today]) {
        _today = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:today options:0];
        [self setNeedsLayout];
    }

With this:

    _today = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:today options:0];
    [self setNeedsLayout];

Removing the if-clause solved my problem. Do you think that I will have big problems by changing this piece of code?

@WenchaoD
Copy link
Owner

@kallahir It seems that what I meant should be [_today isEqualToDate:today]. But that's not very necessary, you can simply remove it. I think it would work well.

@kallahir
Copy link
Contributor Author

Ok, so I think it's done!

Thank you very much!

@kallahir kallahir reopened this Dec 16, 2016
@kallahir
Copy link
Contributor Author

Corrected the problem in the following commit. #515

WenchaoD added a commit that referenced this issue Dec 20, 2016
WenchaoD added a commit that referenced this issue Dec 20, 2016
* master:
  Removing if-clause that makes impossible to change today date.
  Fix issue #514
  Fix issue #502

Conflicts:
	FSCalendar/FSCalendar.m
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