FSCalendar: Date selection and Header title displaying wrong dates, months and year in arabic
Hi @WenchaoD ,
I am using your awesome library again but this time in Arabic in xcode 9 ios 11. I am facing this issue in RLT. When i change the system language the header title is displaying irrelevant date.
This is the code for initial calendar setup.
func setupCalendar(calendarView : FSCalendar){
calendarView.allowsMultipleSelection = false
calendarView.scrollDirection = .horizontal
calendarView.scrollEnabled = true
calendarView.swipeToChooseGesture.isEnabled = true
calendarView.calendarHeaderView.backgroundColor = UIColor.init(hex: "131114")
calendarView.bottomBorder.backgroundColor = UIColor.clear
calendarView.appearance.headerDateFormat = "MMMM - YYYY"
calendarView.appearance.caseOptions = [.headerUsesUpperCase,.weekdayUsesSingleUpperCase]
calendarView.appearance.borderRadius = 0.2
calendarView.appearance.todayColor = currenDateColor
calendarView.appearance.todaySelectionColor = currenDateColor
calendarView.today = nil
}
func minimumDate(for calendar: FSCalendar) -> Date {
return Date()
}
func moveBack(calendarView : FSCalendar){
var val = -1
if language.currentAppleLanguage() == "ar"{
val = 1
}
let gregorian = NSCalendar.init(calendarIdentifier: .gregorian)
let mmdate = gregorian?.date(byAdding: .month, value: val, to: calendarView.currentPage, options: [])
calendarView.setCurrentPage(mmdate!, animated: true)
// let previousMonth = self.gre
// let previousMonth = calendarView.date(bySubstractingMonths: val, from: calendarView.currentPage)
// calendarView.setCurrentPage(previousMonth, animated: true)
//
}
func moveForward(calendarView : FSCalendar){
var val = 1
if language.currentAppleLanguage() == "ar"{
val = -1
}
let gregorian = NSCalendar.init(calendarIdentifier: .gregorian)
let mmdate = gregorian?.date(byAdding: .month, value: val, to: calendarView.currentPage, options: .matchLast)
calendarView.setCurrentPage(mmdate!, animated: true)
}
As you can see the date in header is not correct. When i select a date from the calendar it is displaying wrong date value.
Need help urgently please. Thanks
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 3
- Comments: 41
Commits related to this issue
- Fix bug show today in current page Fix issue [#843](https://github.com/WenchaoD/FSCalendar/issues/843) — committed to Husseinhj/FSCalendar by Husseinhj 5 years ago
@OmarHassan25 I ran your sample project and found the issue. The library is unable to update states, so it displays the wrong year. It is better to use the calendar view in run-time rather than design mode.
Like this:
had the same issue. that’s how I ended up fixing it :
you need to change headerView locale too.
@Husseinhj Thanks a lot for this solution, this solves my problem.
Ok Thank You @Husseinhj
@Husseinhj Shukran Brother!