-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] #391 - 솝마디 메인 뷰 화면 전환 및 데이터 바인딩 #393
Changes from 1 commit
87d1868
39717c3
f103217
4f82a7a
887d520
66d020b
b31184b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- 주어진 날짜가 없다면 오늘 날짜를 사용
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,27 +8,33 @@ | |
|
||
import Foundation | ||
|
||
extension String { | ||
|
||
/** | ||
|
||
- Description: | ||
"yyyy-MM-dd'T'HH:mm:ss" 형태로 주어진 날짜를 원하는 format으로 변경하는 메서드 | ||
/** | ||
|
||
- parameters: | ||
- dateString: 변경하고자 하는 dateformat을 입력합니다. ex. "HH:mm" | ||
|
||
*/ | ||
- Description: | ||
주어진 날짜를 원하는 format으로 변경하는 메서드 | ||
주어진 날짜가 없는 경우 오늘 날짜 반환 | ||
|
||
public func setDateFormat(dateString: String) -> String { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" | ||
dateFormatter.locale = Locale(identifier: "ko_KR") | ||
dateFormatter.timeZone = TimeZone(identifier: "Asia/Seoul") | ||
- parameters: | ||
- dateString: 변경하고자 하는 dateformat을 입력합니다. ex. "HH:mm" | ||
|
||
*/ | ||
|
||
public func setDateFormat(date: String? = nil, from before: String? = nil, to after: String) -> String { | ||
let dateFormatter = DateFormatter() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swift의 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헉 그동안 init 작업의 오버헤드는 고민해보지 않았던 것 같아요 감사합니다 !! |
||
dateFormatter.locale = Locale(identifier: "ko_KR") | ||
dateFormatter.timeZone = TimeZone(identifier: "Asia/Seoul") | ||
|
||
if let dateString = date, | ||
let inputFormat = before { | ||
|
||
guard let date = dateFormatter.date(from: self) else { return "00:00" } | ||
dateFormatter.dateFormat = before | ||
guard let date = dateFormatter.date(from: dateString) else { return "00:00" } | ||
dateFormatter.dateFormat = after | ||
|
||
dateFormatter.dateFormat = dateString | ||
return dateFormatter.string(from: date) | ||
} else { | ||
dateFormatter.dateFormat = after | ||
return dateFormatter.string(from: Date()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫶🏻