[iOS] fix time zone issues in date picker
https://jira.mail.ru/browse/MAPSME-14456
This commit is contained in:
parent
5f4a7c9ad4
commit
06fba64485
2 changed files with 10 additions and 7 deletions
|
@ -12,7 +12,7 @@ public final class DatePickerView: UIView {
|
|||
}
|
||||
}
|
||||
|
||||
var calendar = Locale.current.calendar
|
||||
var calendar = Calendar.autoupdatingCurrent
|
||||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: CalendarLayout())
|
||||
let cellStrategy: CellStrategy
|
||||
var year: Int
|
||||
|
@ -132,7 +132,9 @@ public final class DatePickerView: UIView {
|
|||
}
|
||||
|
||||
private func isActiveDate(_ date: Date) -> Bool {
|
||||
return date >= minimumDate && date <= maximumDate
|
||||
return calendar.isDate(date, inSameDayAs: minimumDate) ||
|
||||
calendar.isDate(date, inSameDayAs: maximumDate) ||
|
||||
(date >= minimumDate && date <= maximumDate)
|
||||
}
|
||||
|
||||
private func positionInRange(_ indexPath: IndexPath) -> PositionInRange {
|
||||
|
@ -142,7 +144,7 @@ public final class DatePickerView: UIView {
|
|||
var state: PositionInRange = .outside
|
||||
guard let startDate = startDate else { return state }
|
||||
|
||||
if calendar.isDate(date, equalTo: startDate, toGranularity: .day) {
|
||||
if calendar.isDate(date, inSameDayAs: startDate) {
|
||||
state = .first
|
||||
}
|
||||
|
||||
|
@ -150,7 +152,7 @@ public final class DatePickerView: UIView {
|
|||
return state == .first ? .single : state
|
||||
}
|
||||
|
||||
if calendar.isDate(date, equalTo: endDate, toGranularity: .day) {
|
||||
if calendar.isDate(date, inSameDayAs: endDate) {
|
||||
state = .last
|
||||
} else if date > startDate && date < endDate {
|
||||
state = .middle
|
||||
|
|
|
@ -158,9 +158,10 @@ unsigned makeMask(std::unordered_set<ftypes::IsHotelChecker::Type> const &items)
|
|||
|
||||
auto &orderingParams = params.m_orderingParams;
|
||||
orderingParams.m_rooms = filterRooms;
|
||||
NSInteger secondsFromGMT = NSTimeZone.systemTimeZone.secondsFromGMT;
|
||||
orderingParams.m_checkin = Clock::from_time_t(self.checkInDate.timeIntervalSince1970 - secondsFromGMT);
|
||||
orderingParams.m_checkout = Clock::from_time_t(self.checkOutDate.timeIntervalSince1970 - secondsFromGMT);
|
||||
NSInteger checkInOffset = [NSTimeZone.systemTimeZone secondsFromGMTForDate:self.checkInDate];
|
||||
NSInteger checkOutOffset = [NSTimeZone.systemTimeZone secondsFromGMTForDate:self.checkOutDate];
|
||||
orderingParams.m_checkin = Clock::from_time_t(self.checkInDate.timeIntervalSince1970 + checkInOffset);
|
||||
orderingParams.m_checkout = Clock::from_time_t(self.checkOutDate.timeIntervalSince1970 + checkOutOffset);
|
||||
}
|
||||
return {std::make_shared<booking::AvailabilityParams>(params), {}};
|
||||
}
|
||||
|
|
Reference in a new issue