Handle UNIX timestamps in String.swiftyDate() method
This commit is contained in:
parent
0b13457b82
commit
161946cb6c
|
@ -50,6 +50,10 @@ extension String {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func swiftyDate(calendar:Calendar = Calendar.current) -> Date? {
|
public func swiftyDate(calendar:Calendar = Calendar.current) -> Date? {
|
||||||
|
if let timestamp = TimeInterval(self) {
|
||||||
|
return Date(timeIntervalSince1970: timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
// is this even a string we can work with?
|
// is this even a string we can work with?
|
||||||
if (self.count < 1) { return nil }
|
if (self.count < 1) { return nil }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue