From e98847179afa6dda742d560bfd97586ef365cbe6 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 14 Nov 2023 12:50:16 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20-=20=EB=82=A0=EC=A7=9C=20=ED=8F=AC=EB=A7=B7=20yyyy?= =?UTF-8?q?=EB=85=84=20MM=EC=9B=94=20dd=EC=9D=BC=20(E)=20a=20hh=EC=8B=9C?= =?UTF-8?q?=20mm=EB=B6=84=20=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/Extensions/StringExtension.swift | 6 +++++- SodaLive/Sources/Live/Room/Detail/LiveDetailView.swift | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SodaLive/Sources/Extensions/StringExtension.swift b/SodaLive/Sources/Extensions/StringExtension.swift index fe2ac94..b7e9f0f 100644 --- a/SodaLive/Sources/Extensions/StringExtension.swift +++ b/SodaLive/Sources/Extensions/StringExtension.swift @@ -14,11 +14,15 @@ extension Optional where Wrapped == String { } extension String { - func convertDateFormat(from: String, to: String) -> String { + func convertDateFormat(from: String, to: String, locale: Locale? = nil) -> String { let fromFormatter = DateFormatter() fromFormatter.dateFormat = from fromFormatter.timeZone = TimeZone(identifier: TimeZone.current.identifier) + if let locale = locale { + fromFormatter.locale = locale + } + if let date = fromFormatter.date(from: self) { return date.convertDateFormat(dateFormat: to) } else { diff --git a/SodaLive/Sources/Live/Room/Detail/LiveDetailView.swift b/SodaLive/Sources/Live/Room/Detail/LiveDetailView.swift index 821796f..2e5b1b4 100644 --- a/SodaLive/Sources/Live/Room/Detail/LiveDetailView.swift +++ b/SodaLive/Sources/Live/Room/Detail/LiveDetailView.swift @@ -94,7 +94,7 @@ struct LiveDetailView: View { .padding(.top, 6.7) HStack(spacing: 0) { - Text(room.beginDateTime) + Text(room.beginDateTime.convertDateFormat(from: "yyyy.MM.dd EEE hh:mm a", to: "yyyy년 MM월 dd일 (E) a hh시 mm분", locale: Locale(identifier: "en_US_POSIX"))) .font(.custom(Font.medium.rawValue, size: 12)) .foregroundColor(Color(hex: "bbbbbb"))