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