@@ -136,31 +136,30 @@ export default {
136
136
return value
137
137
},
138
138
formatDatetimeToModel (newValue , oldValue ) {
139
- let defaultFormat = DATETIME_FORMATS [this .schema .inputType .toLowerCase ()]
140
- let m = fecha .parse (newValue, defaultFormat)
141
- if (m !== false ) {
142
- if (this .schema .format ) {
143
- newValue = fecha .format (m, this .schema .format )
144
- } else {
145
- newValue = m .valueOf ()
139
+ const format = DATETIME_FORMATS [this .schema .inputType .toLowerCase ()]
140
+ if (newValue) {
141
+ let m = fecha .parse (newValue, format)
142
+ if (m !== false ) {
143
+ if (this .schema .format ) {
144
+ newValue = fecha .format (m, this .schema .format )
145
+ } else {
146
+ newValue = m .valueOf ()
147
+ }
146
148
}
147
149
}
148
150
this .updateModelValue (newValue, oldValue)
149
151
},
150
152
formatDatetimeValueToField (value ) {
151
- if (value === null || undefined === value) {
152
- return null
153
- }
153
+ if (! value) return null
154
154
155
- let defaultFormat = DATETIME_FORMATS [this .schema .inputType .toLowerCase ()]
155
+ const format = DATETIME_FORMATS [this .schema .inputType .toLowerCase ()]
156
156
let m = value
157
+
157
158
if (! isNumber (value)) {
158
- m = fecha .parse (value, defaultFormat )
159
+ m = fecha .parse (value, format )
159
160
}
160
- if (m !== false ) {
161
- return fecha .format (m, defaultFormat)
162
- }
163
- return value
161
+
162
+ return m !== false ? fecha .format (m, format) : value
164
163
},
165
164
formatNumberToModel (newValue , oldValue ) {
166
165
if (! isNumber (newValue)) {
0 commit comments