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

Current Selected Date is other than they should be (-1 day) #764

Closed
krystiank907 opened this issue Apr 23, 2018 · 1 comment
Closed

Current Selected Date is other than they should be (-1 day) #764

krystiank907 opened this issue Apr 23, 2018 · 1 comment

Comments

@krystiank907
Copy link

krystiank907 commented Apr 23, 2018

I have problem if I selected day and print this I have date with - 1 day
Problem is when I change firstDayOfWeak, when is default is good.
On the start ViewController I selected currentDay and calendar selected currently date

   let currentDateString = formatter.string(from: Date())
        let cellStateDateString = formatter.string(from: cellState.date)
        if currentDateString ==  cellStateDateString {
                validCell.dataLabel.textColor = selectedMounthColor
                validCell.selectedView.backgroundColor = UIColor.blue
     }

Version 7.1.5
Swift 4
Tested on iPhone X (no on simulator)
My code:

    func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
        calendarView.scrollToDate(Date(), animateScroll: false)
        testCalendar.timeZone = Calendar.current.timeZone
        testCalendar.locale = Calendar.current.locale
        self.formatter.dateFormat = "yyyy MM dd"
        self.formatter.timeZone = Calendar.current.timeZone
        self.formatter.locale = Calendar.current.locale
        let startDate = formatter.date(from: "2017 01 01")
        let endDate = formatter.date(from: "2100 12 28")
        let firstDayOfWeek: DaysOfWeek = .monday // when I don't set value .monday calendar selected currently date
        
        let parametrs = ConfigurationParameters(startDate: startDate!,
                                                endDate: endDate!,
                                                calendar: testCalendar,
                                                firstDayOfWeek: firstDayOfWeek)
        return parametrs
    }
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
        print(date) // date -1Day
        handleCellSelected(view: cell, cellState: cellState)
        handleCellTextColor(view: cell, cellState: cellState)
    }
@patchthecode
Copy link
Owner

This is a very popular question asked for iOS on any calendar library on github.
It happens to people in the East.
We explained it here -> #252

Will close this. Let me know if youre still stuck.

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