date formatting exposure.
This commit is contained in:
parent
4c078d607c
commit
47b82f7e87
@ -22,14 +22,7 @@ import UIKit
|
||||
return calendar
|
||||
}()
|
||||
|
||||
public var formatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeZone = NSTimeZone.system
|
||||
formatter.locale = .current
|
||||
formatter.formatterBehavior = .default
|
||||
return formatter
|
||||
}()
|
||||
public var dateFormat: String?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
@ -90,7 +83,7 @@ import UIKit
|
||||
if calendar.isDate(date, inSameDayAs: Date()) {
|
||||
text = MVMCoreUIUtility.hardcodedString(withKey: "textfield_today_string")
|
||||
} else {
|
||||
text = formatter.string(from: date)
|
||||
text = dateFormatter().string(from: date)
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,6 +97,21 @@ import UIKit
|
||||
|
||||
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
|
||||
@ -113,5 +121,9 @@ extension DateDropdownEntryField {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
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