From dec2c38bbd41e9ea5b3ebcb74799e254a240bb49 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Thu, 25 Mar 2021 23:37:17 +0300 Subject: [PATCH] Fixed bug with wrong date grouping --- AutoCat.xcodeproj/project.pbxproj | 4 ++-- AutoCat/Models/DateSection.swift | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 85cb185..3c8b1e1 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -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; diff --git a/AutoCat/Models/DateSection.swift b/AutoCat/Models/DateSection.swift index 8432e69..936643c 100644 --- a/AutoCat/Models/DateSection.swift +++ b/AutoCat/Models/DateSection.swift @@ -24,20 +24,21 @@ struct DateSection: 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)