Created
October 5, 2018 06:45
-
-
Save fmaxx/762a124bc033574cc9f776a18f1c8093 to your computer and use it in GitHub Desktop.
Date, utilities
This file contains 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 Date { | |
public func toLabel(pattern: String = "HH:mm dd-MM-yy", locale: Locale = .current, abbreviation: String = "GMT") -> String { | |
let dateFormatter = DateFormatter() | |
dateFormatter.timeZone = TimeZone(abbreviation: abbreviation) | |
dateFormatter.locale = locale | |
dateFormatter.dateFormat = pattern | |
return dateFormatter.string(from: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment