 
 import Foundation
-
-struct DateFormat {
-    static let Date = "yyyy-MM-dd"
-    static let DateTime = "yyyy-MM-dd HH:mm:ss ZZZZ"
-}
 
 public extension Date {
     
     public func toDateString() -> String {
-        return format(DateFormat.Date)
+        return format(.Date)
     }
     
     public func toDateTimeString() -> String {
-        return format(DateFormat.DateTime)
+        return format(.DateTime)
     }
     
-    public func format(_ dateFormat: String = DateFormat.DateTime) -> String {
-        return DateFormatter().format(dateFormat: dateFormat).string(from: self)
+    public func format(_ dateFormat: DateFormatter.Format = .DateTime) -> String {
+        return DateFormatter().format(dateFormat: dateFormat.rawValue).string(from: self)
     }
     
-    public init(dateString: String, _ format: String = DateFormat.DateTime) {
+    public init(dateString: String, _ format: DateFormatter.Format = .DateTime) {
         
-        let dateFormatter = DateFormatter().format(dateFormat: format)
+        let dateFormatter = DateFormatter().format(dateFormat: format.rawValue)
         guard let date = dateFormatter.date(from: dateString) else {
             self = Date()
             return

    
}

extension DateFormatter {
    
    public func format(dateFormat: String) -> DateFormatter {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = dateFormat;
        dateFormatter.timeZone = TimeZone.init(secondsFromGMT: -8 * 3600)!;

public extension String {

    public func toDate() -> Date? {
        return format(.Date)
    }
    
    public func toDateTime() -> Date? {
        return format(.DateTime)
    }
    
    func format(_ dateFormat: DateFormatter.Format = .DateTime) -> Date? {
        return DateFormatter().format(dateFormat: dateFormat.rawValue).date(from: self) as Date?
    }
    
    func urlSafeBase64() -> String {
