date formatting exposure.
This commit is contained in:
parent
4c078d607c
commit
47b82f7e87
@ -22,14 +22,7 @@ import UIKit
|
|||||||
return calendar
|
return calendar
|
||||||
}()
|
}()
|
||||||
|
|
||||||
public var formatter: DateFormatter = {
|
public var dateFormat: String?
|
||||||
let formatter = DateFormatter()
|
|
||||||
formatter.dateStyle = .medium
|
|
||||||
formatter.timeZone = NSTimeZone.system
|
|
||||||
formatter.locale = .current
|
|
||||||
formatter.formatterBehavior = .default
|
|
||||||
return formatter
|
|
||||||
}()
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -90,7 +83,7 @@ import UIKit
|
|||||||
if calendar.isDate(date, inSameDayAs: Date()) {
|
if calendar.isDate(date, inSameDayAs: Date()) {
|
||||||
text = MVMCoreUIUtility.hardcodedString(withKey: "textfield_today_string")
|
text = MVMCoreUIUtility.hardcodedString(withKey: "textfield_today_string")
|
||||||
} else {
|
} else {
|
||||||
text = formatter.string(from: date)
|
text = dateFormatter().string(from: date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +97,21 @@ import UIKit
|
|||||||
|
|
||||||
setTextWith(date: datePicker?.date)
|
setTextWith(date: datePicker?.date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func dateFormatter() -> DateFormatter {
|
||||||
|
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
formatter.dateStyle = .medium
|
||||||
|
formatter.timeZone = NSTimeZone.system
|
||||||
|
formatter.locale = .current
|
||||||
|
formatter.formatterBehavior = .default
|
||||||
|
|
||||||
|
if let dateFormat = dateFormat {
|
||||||
|
formatter.dateFormat = dateFormat
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
@ -113,5 +121,9 @@ extension DateDropdownEntryField {
|
|||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|
||||||
guard let dictionary = json, !dictionary.isEmpty else { return }
|
guard let dictionary = json, !dictionary.isEmpty else { return }
|
||||||
|
|
||||||
|
if let dateFormat = dictionary["dateFormat"] as? String {
|
||||||
|
self.dateFormat = dateFormat
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user