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

didSelectDate date and cellState date is different #622

Closed
jackywongcw opened this issue Nov 15, 2017 · 4 comments
Closed

didSelectDate date and cellState date is different #622

jackywongcw opened this issue Nov 15, 2017 · 4 comments

Comments

@jackywongcw
Copy link

jackywongcw commented Nov 15, 2017

Using the latest version: 7.1.3
Test Device : iOS 9

In

func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
        print(" selected date = ", date) // prints: selected date =  2017-11-06 16:00:00 +0000
        print("cellstate text = ", cellState.text) // prints: cellstate text = 7
}

why are they not the same? is it because of timezone?

for the configureCalendar parameter, use:

        let parameter = ConfigurationParameters(startDate: formatter.date(from: "2017 01 01")!,
                                                endDate: formatter.date(from: "2017 01 01")!,
                                                numberOfRows: numberOfRows,
                                                generateOutDates: .tillEndOfRow)
        
        return parameter

formatter is the same setup as per your tutorial
numberOfRows = 1

Can you please check if you're able to replicate this problem?

@patchthecode
Copy link
Owner

patchthecode commented Nov 15, 2017

Let me know if this discussion is helpful to you -> #252

When ever you print dates to the console, always use a formatter to do it.

@jackywongcw
Copy link
Author

Yep. Thanks for the reference. Looks like quite a number of people had the same issue before, my bad for not searching long enough.
Perhaps you can point this out in the tutorial / front page?

Also, what is the purpose of the "date" and "cellState" parameter in didSelectDate / cellForItemAt? What's the initial intention for it?
AFAIK, date and cellState.date returns the same exact date (before the formatter).

@patchthecode
Copy link
Owner

date = cellState.date

originally, the library just had date. Eventually, i added cellState because there are many other things that that were useful to developers. I didn't want to remove date since so many were using it. Therefore, I left date there for easy access as this variable was the most accessed. I may consider removing it in future, and just keeping every thing inside cellSate.

@jackywongcw
Copy link
Author

I see.
Thanks again for your time taken to reply and your awesome library!

Case close. :)

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