patchthecode / JTAppleCalendar

The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable
https://patchthecode.com
MIT License
7.55k stars 806 forks source link

Hi I still can not change the calendar to Persian I used identifier to Persian but its still gregorian #975

Closed babakmuir closed 5 years ago

babakmuir commented 5 years ago

IMPORTANT - BEFORE CREATING YOUR ISSUE PLEASE READ THE FOLLOWING:

  1. PLEASE STATE THE VERSION NUMBER you are using.
  2. Are you using the latest version of JTAppleCalendar? Latest version is currently 7.1.6
  3. PROVIDE ENOUGH INPORMATION SO I CAN RECREATE THE PROBLEM.
patchthecode commented 5 years ago

without seeing code of your

  1. configureCalendar function
  2. cellForItem function

I cannot help.

babakmuir commented 5 years ago
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {

        dateFotmatter.dateFormat = "yyyy/MM/dd"
        dateFotmatter.timeZone = persianCalendar.timeZone
        dateFotmatter.locale = persianCalendar.locale

        let startDate = dateFotmatter.date(from: "1397/04/01")!
        let endDate = dateFotmatter.date(from: "1420/01/01")!

//        let startDate = testFotmatter.date(from: "2017 01 01")!
//        let endDate = testFotmatter.date(from: "2017 12 31")!

        let parameters = ConfigurationParameters(startDate: startDate,
                                                 endDate: endDate,
                                                 numberOfRows: 6,
                                                 calendar: persianCalendar,
                                                 generateInDates: .forAllMonths,
                                                 generateOutDates: .tillEndOfGrid,
                                                 firstDayOfWeek: .saturday)

        return parameters
}

func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {

        let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CustomCell", for: indexPath) as! CustomCell
        cell.dateLabel.text = cellState.text

        handleCellSelected(view: cell, cellState: cellState)
        handleCellTextColor(cell: cell, cellState: cellState)

        return cell
babakmuir commented 5 years ago

I need it to use Persian words and numbers for example I need اردیبهشت but it shows Ordibehesht in month label the same for numbers ۱۲۳...۸۹۰ instead of 123...890

patchthecode commented 5 years ago

so basically you are saying that you want persian language like

اردیبهشت

but instead you are getting english like this?

1 2 3
patchthecode commented 5 years ago

What you are asking isnt really a JTApplecalendar problem. You just need to know how to use date formatter to convert dates into Persian.

Here is how to do it.

        let date = Date()
        let df = DateFormatter()
        df.locale = Locale(identifier: "fa_IR")
        df.calendar = persianCalendar
        df.dateFormat = "dd"
        print(df.string(from: date))

Tell me if this works.

babakmuir commented 5 years ago

Thanks a lot man it worked pretty well I'm new to Xcode and sorry for the obvious question looking forward to learn more

patchthecode commented 5 years ago

cool