From 4fc7cc77ee47e46cbe6e6a6c8a3d38e83d6c5448 Mon Sep 17 00:00:00 2001 From: FreeDeveloper97 Date: Fri, 2 Dec 2022 19:06:02 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20dateFormatter=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EB=AA=A8=EB=91=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project_Timer.xcodeproj/project.pbxproj | 8 ++++---- Project_Timer/Global/Extension/Date+Extension.swift | 6 ++++++ Project_Timer/Global/Model/Dummy.swift | 2 +- Project_Timer/Logs/Dailys/DailysVC.swift | 2 +- .../Logs/Dailys/Graph/StandardDailyGraphView.swift | 4 +--- .../Logs/Dailys/Graph/TasksProgressDailyGraphView.swift | 4 +--- .../Logs/Dailys/Graph/TimelineDailyGraphView.swift | 4 +--- Project_Timer/Logs/LogHome/SwiftUI/DailyView.swift | 4 +--- Project_Timer/Logs/LogHome/SwiftUI/WeekView.swift | 4 +--- Project_Timer/Logs/ModifyRecord/ModifyRecordVC.swift | 5 +---- .../Logs/Weeks/Graph/StandardWeekGraphView.swift | 4 +--- Project_Timer/Logs/Weeks/WeeksVC.swift | 2 +- 12 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Project_Timer.xcodeproj/project.pbxproj b/Project_Timer.xcodeproj/project.pbxproj index 293a524b..0fcc2540 100644 --- a/Project_Timer.xcodeproj/project.pbxproj +++ b/Project_Timer.xcodeproj/project.pbxproj @@ -1502,7 +1502,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Project_Timer/Project_Timer.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 2C96RNDN63; INFOPLIST_FILE = Project_Timer/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -1510,7 +1510,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.8.1; + MARKETING_VERSION = 7.8.2; PRODUCT_BUNDLE_IDENTIFIER = com.FDEE.TiTi; PRODUCT_NAME = TiTi; SUPPORTS_MACCATALYST = YES; @@ -1527,7 +1527,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Project_Timer/Project_Timer.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 2C96RNDN63; INFOPLIST_FILE = Project_Timer/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 14.0; @@ -1535,7 +1535,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.8.1; + MARKETING_VERSION = 7.8.2; PRODUCT_BUNDLE_IDENTIFIER = com.FDEE.TiTi; PRODUCT_NAME = TiTi; SUPPORTS_MACCATALYST = YES; diff --git a/Project_Timer/Global/Extension/Date+Extension.swift b/Project_Timer/Global/Extension/Date+Extension.swift index d6e89a1f..94548ca9 100644 --- a/Project_Timer/Global/Extension/Date+Extension.swift +++ b/Project_Timer/Global/Extension/Date+Extension.swift @@ -27,6 +27,12 @@ extension Date { return dateFormatter.string(from: self) } + var YYYYMMstypeString: String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy.MM" + return dateFormatter.string(from: self) + } + var HHmmssStyleString: String { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "HH:mm:ss" diff --git a/Project_Timer/Global/Model/Dummy.swift b/Project_Timer/Global/Model/Dummy.swift index 9acc686f..495dfb47 100644 --- a/Project_Timer/Global/Model/Dummy.swift +++ b/Project_Timer/Global/Model/Dummy.swift @@ -73,7 +73,7 @@ struct Dummy { static func getDumyDays(_ stringDays: [String]) -> [Date] { var days: [Date] = [] let formatter = DateFormatter() - formatter.dateFormat = "YYYY.MM.dd" + formatter.dateFormat = "yyyy.MM.dd" for day in stringDays { let tempDay: Date = formatter.date(from: day)! days.append(tempDay) diff --git a/Project_Timer/Logs/Dailys/DailysVC.swift b/Project_Timer/Logs/Dailys/DailysVC.swift index 5e6b5db1..1c95d729 100644 --- a/Project_Timer/Logs/Dailys/DailysVC.swift +++ b/Project_Timer/Logs/Dailys/DailysVC.swift @@ -139,7 +139,7 @@ extension DailysVC { private func configureCalender() { self.calendar.delegate = self self.calendar.dataSource = self - self.calendar.appearance.headerDateFormat = "YYYY.MM" + self.calendar.appearance.headerDateFormat = "yyyy.MM" self.calendar.appearance.headerTitleFont = TiTiFont.HGGGothicssiP80g(size: 25) self.calendar.appearance.weekdayFont = TiTiFont.HGGGothicssiP80g(size: 13) self.calendar.appearance.titleFont = TiTiFont.HGGGothicssiP60g(size: 18) diff --git a/Project_Timer/Logs/Dailys/Graph/StandardDailyGraphView.swift b/Project_Timer/Logs/Dailys/Graph/StandardDailyGraphView.swift index c2992747..b6a9239e 100644 --- a/Project_Timer/Logs/Dailys/Graph/StandardDailyGraphView.swift +++ b/Project_Timer/Logs/Dailys/Graph/StandardDailyGraphView.swift @@ -247,9 +247,7 @@ extension StandardDailyGraphView { return } - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM.dd" - self.dateLabel.text = dateFormatter.string(from: day) + self.dateLabel.text = day.YYYYMMDDstyleString } private func updateDayOfWeek(_ day: Date?) { diff --git a/Project_Timer/Logs/Dailys/Graph/TasksProgressDailyGraphView.swift b/Project_Timer/Logs/Dailys/Graph/TasksProgressDailyGraphView.swift index 079247dd..73e66645 100644 --- a/Project_Timer/Logs/Dailys/Graph/TasksProgressDailyGraphView.swift +++ b/Project_Timer/Logs/Dailys/Graph/TasksProgressDailyGraphView.swift @@ -138,8 +138,6 @@ extension TasksProgressDailyGraphView { return } - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM.dd" - self.dateLabel.text = dateFormatter.string(from: day) + self.dateLabel.text = day.YYYYMMDDstyleString } } diff --git a/Project_Timer/Logs/Dailys/Graph/TimelineDailyGraphView.swift b/Project_Timer/Logs/Dailys/Graph/TimelineDailyGraphView.swift index 1d31a03e..6a6674a4 100644 --- a/Project_Timer/Logs/Dailys/Graph/TimelineDailyGraphView.swift +++ b/Project_Timer/Logs/Dailys/Graph/TimelineDailyGraphView.swift @@ -163,9 +163,7 @@ extension TimelineDailyGraphView { return } - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM.dd" - self.dateLabel.text = dateFormatter.string(from: day) + self.dateLabel.text = day.YYYYMMDDstyleString } private func updateDayOfWeek(_ day: Date?) { diff --git a/Project_Timer/Logs/LogHome/SwiftUI/DailyView.swift b/Project_Timer/Logs/LogHome/SwiftUI/DailyView.swift index e29487c8..cf13be92 100644 --- a/Project_Timer/Logs/LogHome/SwiftUI/DailyView.swift +++ b/Project_Timer/Logs/LogHome/SwiftUI/DailyView.swift @@ -76,9 +76,7 @@ extension DailyView { // MARK: Propertys extension DailyView { private var dateText: String { - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM.dd" - return dateFormatter.string(from: viewModel.day.zeroDate.localDate) + return viewModel.day.zeroDate.localDate.YYYYMMDDstyleString } private func timeColor(time: Int) -> Color { diff --git a/Project_Timer/Logs/LogHome/SwiftUI/WeekView.swift b/Project_Timer/Logs/LogHome/SwiftUI/WeekView.swift index 669b53ce..078aabbc 100644 --- a/Project_Timer/Logs/LogHome/SwiftUI/WeekView.swift +++ b/Project_Timer/Logs/LogHome/SwiftUI/WeekView.swift @@ -103,9 +103,7 @@ extension WeekView { extension WeekView { private var monthText: String { guard let day = viewModel.weekDates.last else { return "0000.00" } - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM" - return dateFormatter.string(from: day) + return day.YYYYMMstypeString } private var weekText: String { diff --git a/Project_Timer/Logs/ModifyRecord/ModifyRecordVC.swift b/Project_Timer/Logs/ModifyRecord/ModifyRecordVC.swift index 033f516c..8882abf5 100644 --- a/Project_Timer/Logs/ModifyRecord/ModifyRecordVC.swift +++ b/Project_Timer/Logs/ModifyRecord/ModifyRecordVC.swift @@ -91,10 +91,7 @@ extension ModifyRecordVC { private func configureTitle() { guard let day = self.viewModel?.currentDaily.day else { return } - - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM.dd" - self.title = dateFormatter.string(from: day) + self.title = day.YYYYMMDDstyleString } private func configureSaveButton() { diff --git a/Project_Timer/Logs/Weeks/Graph/StandardWeekGraphView.swift b/Project_Timer/Logs/Weeks/Graph/StandardWeekGraphView.swift index 96c000ee..ba2dbc78 100644 --- a/Project_Timer/Logs/Weeks/Graph/StandardWeekGraphView.swift +++ b/Project_Timer/Logs/Weeks/Graph/StandardWeekGraphView.swift @@ -262,9 +262,7 @@ extension StandardWeekGraphView { return } - let dateFormatter = DateFormatter() - dateFormatter.dateFormat = "YYYY.MM" - self.monthLabel.text = dateFormatter.string(from: day) + self.monthLabel.text = day.YYYYMMstypeString } private func updateWeekNumLabel(_ num: Int) { diff --git a/Project_Timer/Logs/Weeks/WeeksVC.swift b/Project_Timer/Logs/Weeks/WeeksVC.swift index e5d1f697..51fd256c 100644 --- a/Project_Timer/Logs/Weeks/WeeksVC.swift +++ b/Project_Timer/Logs/Weeks/WeeksVC.swift @@ -92,7 +92,7 @@ extension WeeksVC { private func configureCalender() { self.calendar.delegate = self self.calendar.dataSource = self - self.calendar.appearance.headerDateFormat = "YYYY.MM" + self.calendar.appearance.headerDateFormat = "yyyy.MM" self.calendar.appearance.headerTitleFont = TiTiFont.HGGGothicssiP80g(size: 25) self.calendar.appearance.weekdayFont = TiTiFont.HGGGothicssiP80g(size: 13) self.calendar.appearance.titleFont = TiTiFont.HGGGothicssiP60g(size: 18)