reworked gaurd statement
This commit is contained in:
parent
307b24af1b
commit
7df2fa5b1e
|
@ -59,16 +59,14 @@ struct ArticleItemView: View {
|
||||||
func pubDate(_ dateString: String) -> String {
|
func pubDate(_ dateString: String) -> String {
|
||||||
let dateFormatter = DateFormatter()
|
let dateFormatter = DateFormatter()
|
||||||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"
|
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"
|
||||||
let date = dateFormatter.date(from: dateString)
|
guard let date = dateFormatter.date(from: dateString) else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
let displayFormatter = DateFormatter()
|
let displayFormatter = DateFormatter()
|
||||||
displayFormatter.dateStyle = .medium
|
displayFormatter.dateStyle = .medium
|
||||||
displayFormatter.timeStyle = .none
|
displayFormatter.timeStyle = .none
|
||||||
|
|
||||||
guard let dateFromDateFormatter = date else {
|
return displayFormatter.string(from: date)
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return displayFormatter.string(from: dateFromDateFormatter)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue