Fixing date search params

This commit is contained in:
Selim Mustafaev 2022-09-22 23:55:33 +03:00
parent 078972d149
commit ef90973ef8
2 changed files with 14 additions and 6 deletions

View File

@ -1080,7 +1080,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 91; CURRENT_PROJECT_VERSION = 94;
DEVELOPMENT_TEAM = 46DTTB8X4S; DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;
@ -1105,7 +1105,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 91; CURRENT_PROJECT_VERSION = 94;
DEVELOPMENT_TEAM = 46DTTB8X4S; DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0; IPHONEOS_DEPLOYMENT_TARGET = 13.0;

View File

@ -122,14 +122,14 @@ class FiltersController: FormViewController {
row.noValueDisplayText = NSLocalizedString("Beginning", comment: "") row.noValueDisplayText = NSLocalizedString("Beginning", comment: "")
row.value = self.filter.fromDateUpdated row.value = self.filter.fromDateUpdated
} }
.onChange { self.filter.fromDateUpdated = $0.value } .onChange { self.filter.fromDateUpdated = self.nullifyTime(of: $0.value) }
.cellUpdate(self.update(cell:row:)) .cellUpdate(self.update(cell:row:))
<<< DateInlineRow("ToDateUpdated") { row in <<< DateInlineRow("ToDateUpdated") { row in
row.title = NSLocalizedString("To", comment: "") row.title = NSLocalizedString("To", comment: "")
row.noValueDisplayText = NSLocalizedString("Now", comment: "") row.noValueDisplayText = NSLocalizedString("Now", comment: "")
row.value = self.filter.toDateUpdated row.value = self.filter.toDateUpdated
} }
.onChange { self.filter.toDateUpdated = $0.value } .onChange { self.filter.toDateUpdated = self.nullifyTime(of: $0.value) }
.cellUpdate(self.update(cell:row:)) .cellUpdate(self.update(cell:row:))
form +++ Section(NSLocalizedString("Added time", comment: "")) form +++ Section(NSLocalizedString("Added time", comment: ""))
@ -138,14 +138,14 @@ class FiltersController: FormViewController {
row.noValueDisplayText = NSLocalizedString("Beginning", comment: "") row.noValueDisplayText = NSLocalizedString("Beginning", comment: "")
row.value = self.filter.fromDate row.value = self.filter.fromDate
} }
.onChange { self.filter.fromDate = $0.value } .onChange { self.filter.fromDate = self.nullifyTime(of: $0.value) }
.cellUpdate(self.update(cell:row:)) .cellUpdate(self.update(cell:row:))
<<< DateInlineRow("ToDate") { row in <<< DateInlineRow("ToDate") { row in
row.title = NSLocalizedString("To", comment: "") row.title = NSLocalizedString("To", comment: "")
row.noValueDisplayText = NSLocalizedString("Now", comment: "") row.noValueDisplayText = NSLocalizedString("Now", comment: "")
row.value = self.filter.toDate row.value = self.filter.toDate
} }
.onChange { self.filter.toDate = $0.value } .onChange { self.filter.toDate = self.nullifyTime(of: $0.value) }
.cellUpdate(self.update(cell:row:)) .cellUpdate(self.update(cell:row:))
form +++ Section(NSLocalizedString("Sort", comment: "Header section. Noun.")) form +++ Section(NSLocalizedString("Sort", comment: "Header section. Noun."))
@ -236,4 +236,12 @@ class FiltersController: FormViewController {
row.baseCell.accessoryView = nil row.baseCell.accessoryView = nil
row.baseCell.update() row.baseCell.update()
} }
func nullifyTime(of date: Date?) -> Date? {
guard let date else {
return nil
}
return Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: date)
}
} }