Open ghost opened 7 years ago
Agree, the issue exists in many languages. Here is the temp solution I used until this will be fixed:
import Foundation
import FSCalendar
private let swizzling: (AnyClass, Selector, Selector) -> () = { forClass, originalSelector, swizzledSelector in
let originalMethod = class_getInstanceMethod(forClass, originalSelector)
let swizzledMethod = class_getInstanceMethod(forClass, swizzledSelector)
method_exchangeImplementations(originalMethod, swizzledMethod)
}
extension FSCalendarStickyHeader {
open override class func initialize() {
guard self === FSCalendarStickyHeader.self else { return }
let originalSelector = Selector("setMonth:")
let swizzledSelector = #selector(setMonth(month:))
swizzling(self, originalSelector, swizzledSelector)
}
func setMonth(month: NSDate) {
setMonth(month: month)
titleLabel.text = DateFormatter.monthFormatter.string(from: month as Date).capitalized
}
}
import Foundation
extension DateFormatter {
///Returns date formatter with template
convenience init(withTemplate template: String) {
assert(template.characters.count > 0)
let template = DateFormatter.dateFormat(fromTemplate: template, options: 0, locale: Locale.current)
self.init()
self.dateFormat = template
}
static let monthFormatter: DateFormatter = {
return DateFormatter(withTemplate: "MMMM")
}()
}
hence not usable in many languages.
In file FSCalendarHeaderView.m
(void)configureCell:(FSCalendarHeaderCell )cell atIndexPath:(NSIndexPath )indexPath { case FSCalendarScopeMonth: { //... //... text = [_calendar.formatter stringFromDate:date]; //1 } } 1 could be changed to sth. like
NSDateComponents *cc = [self.calendar.gregorian components:(NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:date];
text = [NSString stringWithFormat:@"%@ %ld", _calendar.formatter.standaloneMonthSymbols[cc.month - 1], (long)cc.year];