From 161946cb6c5f43860a2cfd194ddd1b6c110f6943 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Thu, 2 May 2019 15:02:52 -0500 Subject: [PATCH] Handle UNIX timestamps in String.swiftyDate() method --- Sources/String+SwiftyDates.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/String+SwiftyDates.swift b/Sources/String+SwiftyDates.swift index 0453dab..9927e1e 100644 --- a/Sources/String+SwiftyDates.swift +++ b/Sources/String+SwiftyDates.swift @@ -50,6 +50,10 @@ extension String { } 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? if (self.count < 1) { return nil }