Fixed bug with wrong date grouping
This commit is contained in:
parent
b7a3efcd23
commit
dec2c38bbd
@ -847,7 +847,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 69;
|
||||
CURRENT_PROJECT_VERSION = 71;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
@ -871,7 +871,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 69;
|
||||
CURRENT_PROJECT_VERSION = 71;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
|
||||
@ -24,20 +24,21 @@ struct DateSection<T>: Differentiable, DifferentiableSection, Hashable where T:
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .medium
|
||||
|
||||
let now = Date()
|
||||
let now = DateInRegion(Date(), region: Region.current)
|
||||
let monthStart = now.dateAtStartOf(.month)
|
||||
let weekStart = now.dateAtStartOf(.weekOfMonth)
|
||||
|
||||
let date = Date(timeIntervalSince1970: timestamp)
|
||||
if date.isToday {
|
||||
let dateInRegion = DateInRegion(date, region: Region.current)
|
||||
if dateInRegion.isToday {
|
||||
self.header = NSLocalizedString("Today", comment: "")
|
||||
}
|
||||
else if date.isYesterday {
|
||||
else if dateInRegion.isYesterday {
|
||||
self.header = NSLocalizedString("Yesterday", comment: "")
|
||||
} else if date.isAfterDate(weekStart, granularity: .day) {
|
||||
} else if dateInRegion.isAfterDate(weekStart, granularity: .day) {
|
||||
formatter.dateFormat = "EEEE"
|
||||
self.header = formatter.string(from: date)
|
||||
} else if date.isAfterDate(monthStart, orEqual: false, granularity: .day) {
|
||||
} else if dateInRegion.isAfterDate(monthStart, orEqual: false, granularity: .day) {
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .none
|
||||
self.header = formatter.string(from: date)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user