Skip to content

Commit

Permalink
Merge pull request #365 from kvyatkovskys/feature/v_0.6.25
Browse files Browse the repository at this point in the history
fixed the issue with locale to calculate days in month
  • Loading branch information
kvyatkovskys authored Aug 2, 2024
2 parents 5e037b4 + 6304346 commit 010b5f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Example/KVKCalendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES;
};
name = Debug;
};
Expand Down Expand Up @@ -659,6 +660,7 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion KVKCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KVKCalendar'
s.version = '0.6.24'
s.version = '0.6.25'
s.summary = 'A most fully customization calendar for Apple platforms.'

s.description = <<-DESC
Expand Down
3 changes: 2 additions & 1 deletion Sources/KVKCalendar/CalendarData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ struct CalendarData {

let formatterDay = DateFormatter()
formatterDay.dateFormat = "EE"
formatterDay.locale = style.locale
// MARK: here we have to use `en_US` locale
formatterDay.locale = Locale(identifier: "en_US")
let days = arrDates.map({ Day(type: DayType(rawValue: formatterDay.string(from: $0).uppercased()) ?? .empty, date: $0, data: []) })
return days
}
Expand Down
25 changes: 10 additions & 15 deletions Sources/KVKCalendar/MonthView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,11 @@ extension MonthView: UICollectionViewDelegate, UICollectionViewDelegateFlowLayou

let month = parameters.monthData.data.months[index.section]
setHeaderTitleAndNotify(month.date)
guard style.month.autoSelectionDateWhenScrolling else { return }
let newDate = parameters.monthData.findNextDateInMonth(month)
guard parameters.monthData.date != newDate else { return }

parameters.monthData.date = newDate
willSelectDate?(newDate)

guard style.month.autoSelectionDateWhenScrolling && parameters.monthData.date != newDate else { return }
parameters.monthData.date = newDate
reload()
}

Expand All @@ -452,12 +451,11 @@ extension MonthView: UICollectionViewDelegate, UICollectionViewDelegateFlowLayou

let month = parameters.monthData.data.months[visibleIndex]
setHeaderTitleAndNotify(month.date)
guard style.month.autoSelectionDateWhenScrolling else { return }
let newDate = parameters.monthData.findNextDateInMonth(month)
guard parameters.monthData.date != newDate else { return }
willSelectDate?(newDate)

guard style.month.autoSelectionDateWhenScrolling && parameters.monthData.date != newDate else { return }
parameters.monthData.date = newDate
willSelectDate?(newDate)
reload()
}

Expand All @@ -467,9 +465,11 @@ extension MonthView: UICollectionViewDelegate, UICollectionViewDelegateFlowLayou

switch style.month.selectionMode {
case .multiple:
parameters.monthData.selectedDates = parameters.monthData.updateSelectedDates(parameters.monthData.selectedDates,
date: date,
calendar: style.calendar)
parameters.monthData.selectedDates = parameters.monthData.updateSelectedDates(
parameters.monthData.selectedDates,
date: date,
calendar: style.calendar
)
didSelectDates(parameters.monthData.selectedDates.compactMap({ $0 }), indexPath: item.indexPath)
case .single:
didSelectDates([date], indexPath: item.indexPath)
Expand All @@ -487,7 +487,6 @@ extension MonthView: UICollectionViewDelegate, UICollectionViewDelegateFlowLayou

let width: CGFloat
let height: CGFloat

let heightSectionHeader = style.month.heightSectionHeader
switch style.month.scrollDirection {
case .horizontal:
Expand All @@ -503,17 +502,14 @@ extension MonthView: UICollectionViewDelegate, UICollectionViewDelegateFlowLayou
} else {
width = 0
}

var superViewHeight = collectionView.bounds.height
if !style.month.isHiddenSectionHeader && superViewHeight >= heightSectionHeader {
superViewHeight -= heightSectionHeader
}

height = superViewHeight / CGFloat(item.weeks)
@unknown default:
fatalError()
}

return CGSize(width: width, height: height)
}

Expand All @@ -534,7 +530,6 @@ extension MonthView: UICollectionViewDelegate, UICollectionViewDelegateFlowLayou
guard !style.month.isHiddenSectionHeader else { return .zero }

let item = getActualCachedDay(indexPath: IndexPath(row: 0, section: section))

if let date = item.day?.date, let size = delegate?.sizeForHeader(date, type: .month) {
return size
} else {
Expand Down

0 comments on commit 010b5f2

Please sign in to comment.