This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func iso8601Value() -> Date? { | |
let theDate = self | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ" | |
let date = formatter.date(from: theDate as String) | |
return date | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIColor { | |
static func colorFromHex(_ hex: String) -> UIColor { | |
var hexString = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() | |
if hexString.hasPrefix("#") { | |
hexString.remove(at: hexString.startIndex) | |
} | |
if hexString.count != 6 { | |
return UIColor.magenta | |
} |