@@ -94,7 +94,7 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
9494 } ( )
9595
9696 private lazy var weekView : WeekView = {
97- let view = WeekView ( config: self . config. weekView)
97+ let view = WeekView ( calendar : self . config . calendar , config: self . config. weekView)
9898 view. translatesAutoresizingMaskIntoConstraints = false
9999 return view
100100 } ( )
@@ -139,7 +139,6 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
139139 private let dayCellReuseIdentifier = " DayCellReuseIdentifier "
140140 private let monthHeaderReuseIdentifier = " MonthHeaderReuseIdentifier "
141141 private var viewConfigs : [ IndexPath : DayCell . ViewConfig ] = [ : ]
142- private var currentCalendar : Calendar = . autoupdatingCurrent
143142 private var privateMinimumDate : Date ?
144143 private var privateMaximumDate : Date ?
145144 private var privateSelectMonthOnHeaderTap : Bool = false
@@ -347,7 +346,8 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
347346 let newConfig = DayCell . makeViewConfig ( for: cellState,
348347 minimumDate: self . privateMinimumDate,
349348 maximumDate: self . privateMaximumDate,
350- rangeValue: self . value as? FastisRange )
349+ rangeValue: self . value as? FastisRange ,
350+ calendar: self . config. calendar)
351351 self . viewConfigs [ indexPath] = newConfig
352352 cell. applyConfig ( self . config)
353353 cell. configure ( for: newConfig)
@@ -399,23 +399,23 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
399399 let dateRangeChangesDisabled = !allowDateRangeChanges
400400 let rangeSelected = !currentValue. fromDate. isInSameDay ( date: currentValue. toDate)
401401 if dateRangeChangesDisabled && rangeSelected {
402- newValue = . from( date. startOfDay ( in: self . currentCalendar ) , to: date. endOfDay ( in: self . currentCalendar ) )
403- } else if date. isInSameDay ( in: self . currentCalendar , date: currentValue. fromDate) {
404- let newToDate = date. endOfDay ( in: self . currentCalendar )
402+ newValue = . from( date. startOfDay ( in: self . config . calendar ) , to: date. endOfDay ( in: self . config . calendar ) )
403+ } else if date. isInSameDay ( in: self . config . calendar , date: currentValue. fromDate) {
404+ let newToDate = date. endOfDay ( in: self . config . calendar )
405405 newValue = . from( currentValue. fromDate, to: newToDate)
406- } else if date. isInSameDay ( in: self . currentCalendar , date: currentValue. toDate) {
407- let newFromDate = date. startOfDay ( in: self . currentCalendar )
406+ } else if date. isInSameDay ( in: self . config . calendar , date: currentValue. toDate) {
407+ let newFromDate = date. startOfDay ( in: self . config . calendar )
408408 newValue = . from( newFromDate, to: currentValue. toDate)
409409 } else if date < currentValue. fromDate {
410- let newFromDate = date. startOfDay ( in: self . currentCalendar )
410+ let newFromDate = date. startOfDay ( in: self . config . calendar )
411411 newValue = . from( newFromDate, to: currentValue. toDate)
412412 } else {
413- let newToDate = date. endOfDay ( in: self . currentCalendar )
413+ let newToDate = date. endOfDay ( in: self . config . calendar )
414414 newValue = . from( currentValue. fromDate, to: newToDate)
415415 }
416416
417417 } else {
418- newValue = . from( date. startOfDay ( in: self . currentCalendar ) , to: date. endOfDay ( in: self . currentCalendar ) )
418+ newValue = . from( date. startOfDay ( in: self . config . calendar ) , to: date. endOfDay ( in: self . config . calendar ) )
419419 }
420420
421421 self . value = newValue as? Value
@@ -441,30 +441,30 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
441441
442442 let dateFormatter = DateFormatter ( )
443443 dateFormatter. dateFormat = " yyyy MM dd "
444- dateFormatter. timeZone = self . currentCalendar . timeZone
445- dateFormatter. locale = self . currentCalendar . locale
444+ dateFormatter. timeZone = self . config . calendar . timeZone
445+ dateFormatter. locale = self . config . calendar . locale
446446 var startDate = dateFormatter. date ( from: " 2000 01 01 " ) !
447447 var endDate = dateFormatter. date ( from: " 2030 12 01 " ) !
448448
449449 if let maximumDate = self . privateMaximumDate,
450- let endOfNextMonth = self . currentCalendar . date ( byAdding: . month, value: 2 , to: maximumDate) ?
451- . endOfMonth ( in: self . currentCalendar ) {
450+ let endOfNextMonth = self . config . calendar . date ( byAdding: . month, value: 2 , to: maximumDate) ?
451+ . endOfMonth ( in: self . config . calendar ) {
452452 endDate = endOfNextMonth
453453 }
454454
455455 if let minimumDate = self . privateMinimumDate,
456- let startOfPreviousMonth = self . currentCalendar . date ( byAdding: . month, value: - 2 , to: minimumDate) ?
457- . startOfMonth ( in: self . currentCalendar ) {
456+ let startOfPreviousMonth = self . config . calendar . date ( byAdding: . month, value: - 2 , to: minimumDate) ?
457+ . startOfMonth ( in: self . config . calendar ) {
458458 startDate = startOfPreviousMonth
459459 }
460460
461461 let parameters = ConfigurationParameters ( startDate: startDate,
462462 endDate: endDate,
463463 numberOfRows: 6 ,
464- calendar: self . currentCalendar ,
464+ calendar: self . config . calendar ,
465465 generateInDates: . forAllMonths,
466466 generateOutDates: . tillEndOfRow,
467- firstDayOfWeek: . monday ,
467+ firstDayOfWeek: nil ,
468468 hasStrictBoundaries: true )
469469 return parameters
470470 }
@@ -475,16 +475,16 @@ open class FastisController<Value: FastisValue>: UIViewController, JTACMonthView
475475 header. configure ( for: range. start)
476476 if self . privateSelectMonthOnHeaderTap, Value . mode == . range {
477477 header. tapHandler = {
478- var fromDate = range. start. startOfMonth ( in: self . currentCalendar )
479- var toDate = range. start. endOfMonth ( in: self . currentCalendar )
478+ var fromDate = range. start. startOfMonth ( in: self . config . calendar )
479+ var toDate = range. start. endOfMonth ( in: self . config . calendar )
480480 if let minDate = self . minimumDate {
481481 if toDate < minDate { return } else if fromDate < minDate {
482- fromDate = minDate. startOfDay ( in: self . currentCalendar )
482+ fromDate = minDate. startOfDay ( in: self . config . calendar )
483483 }
484484 }
485485 if let maxDate = self . maximumDate {
486486 if fromDate > maxDate { return } else if toDate > maxDate {
487- toDate = maxDate. endOfDay ( in: self . currentCalendar )
487+ toDate = maxDate. endOfDay ( in: self . config . calendar )
488488 }
489489 }
490490 let newValue : FastisRange = . from( fromDate, to: toDate)
0 commit comments