Skip to content

Commit

Permalink
reworked gaurd statement
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartbreckenridge committed Apr 13, 2021
1 parent 307b24a commit 7df2fa5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Widget/Shared Views/ArticleItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 7df2fa5

Please sign in to comment.