@@ -15,10 +15,6 @@ define([
15
15
16
16
timeOffset : 0 ,
17
17
18
- showsTime : false ,
19
-
20
- dateFormat : 'MM/dd/y' , // ICU Date Format
21
- timeFormat : 'HH:mm' , // ICU Time Format
22
18
validationParams : {
23
19
dateFormat : '${ $.outputDateFormat }'
24
20
} ,
@@ -28,7 +24,7 @@ define([
28
24
* server (ICU Date Format).
29
25
*
30
26
* Used only in date picker mode
31
- * (this.showsTime == false).
27
+ * (this.options. showsTime == false).
32
28
*
33
29
* @type {String }
34
30
*/
@@ -39,7 +35,7 @@ define([
39
35
* server (ICU Date Format).
40
36
*
41
37
* Used only in date picker mode
42
- * (this.showsTime == false).
38
+ * (this.options. showsTime == false).
43
39
*
44
40
* @type {String }
45
41
*/
@@ -51,7 +47,10 @@ define([
51
47
*
52
48
* @type {String }
53
49
*/
54
- datetimeFormat : '' ,
50
+ pickerDateTimeFormat : '' ,
51
+
52
+ pickerDefaultDateFormat : 'MM/dd/y' , // ICU Date Format
53
+ pickerDefaultTimeFormat : 'h:mm a' , // ICU Time Format
55
54
56
55
elementTmpl : 'ui/form/element/date' ,
57
56
@@ -78,13 +77,15 @@ define([
78
77
initConfig : function ( ) {
79
78
this . _super ( ) ;
80
79
81
- utils . extend ( this . options , {
82
- showsTime : this . showsTime ,
83
- timeFormat : this . timeFormat ,
84
- dateFormat : this . dateFormat
85
- } ) ;
80
+ if ( ! this . options . dateFormat ) {
81
+ this . options . dateFormat = this . pickerDefaultDateFormat ;
82
+ }
83
+
84
+ if ( ! this . options . timeFormat ) {
85
+ this . options . timeFormat = this . pickerDefaultTimeFormat ;
86
+ }
86
87
87
- this . prepareDatetimeFormats ( ) ;
88
+ this . prepareDateTimeFormats ( ) ;
88
89
89
90
return this ;
90
91
} ,
@@ -107,15 +108,15 @@ define([
107
108
shiftedValue ;
108
109
109
110
if ( value ) {
110
- if ( this . showsTime ) {
111
+ if ( this . options . showsTime ) {
111
112
shiftedValue = moment . utc ( value ) . add ( this . timeOffset , 'seconds' ) ;
112
113
} else {
113
114
dateFormat = this . shiftedValue ( ) ? this . outputDateFormat : this . inputDateFormat ;
114
115
115
116
shiftedValue = moment ( value , dateFormat ) ;
116
117
}
117
118
118
- shiftedValue = shiftedValue . format ( this . datetimeFormat ) ;
119
+ shiftedValue = shiftedValue . format ( this . pickerDateTimeFormat ) ;
119
120
} else {
120
121
shiftedValue = '' ;
121
122
}
@@ -135,12 +136,11 @@ define([
135
136
var value ;
136
137
137
138
if ( shiftedValue ) {
138
-
139
- if ( this . showsTime ) {
140
- value = moment . utc ( shiftedValue , this . datetimeFormat ) ;
139
+ if ( this . options . showsTime ) {
140
+ value = moment . utc ( shiftedValue , this . pickerDateTimeFormat ) ;
141
141
value = value . subtract ( this . timeOffset , 'seconds' ) . toISOString ( ) ;
142
142
} else {
143
- value = moment ( shiftedValue , this . datetimeFormat ) ;
143
+ value = moment ( shiftedValue , this . pickerDateTimeFormat ) ;
144
144
value = value . format ( this . outputDateFormat ) ;
145
145
}
146
146
} else {
@@ -156,17 +156,22 @@ define([
156
156
* Prepares and converts all date/time formats to be compatible
157
157
* with moment.js library.
158
158
*/
159
- prepareDatetimeFormats : function ( ) {
160
- this . datetimeFormat = this . dateFormat ;
159
+ prepareDateTimeFormats : function ( ) {
160
+ this . pickerDateTimeFormat = this . options . dateFormat ;
161
161
162
- if ( this . showsTime ) {
163
- this . datetimeFormat += ' ' + this . timeFormat ;
162
+ if ( this . options . showsTime ) {
163
+ this . pickerDateTimeFormat += ' ' + this . options . timeFormat ;
164
164
}
165
165
166
- this . datetimeFormat = utils . normalizeDate ( this . datetimeFormat ) ;
166
+ this . pickerDateTimeFormat = utils . normalizeDate ( this . pickerDateTimeFormat ) ;
167
+
168
+ if ( this . dateFormat ) {
169
+ this . inputDateFormat = this . dateFormat ;
170
+ }
167
171
168
172
this . inputDateFormat = utils . normalizeDate ( this . inputDateFormat ) ;
169
173
this . outputDateFormat = utils . normalizeDate ( this . outputDateFormat ) ;
174
+
170
175
this . validationParams . dateFormat = this . outputDateFormat ;
171
176
}
172
177
} ) ;
0 commit comments