@@ -15,17 +15,12 @@ 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
-
23
18
/**
24
19
* Format of date that comes from the
25
20
* server (ICU Date Format).
26
21
*
27
22
* Used only in date picker mode
28
- * (this.showsTime == false).
23
+ * (this.options. showsTime == false).
29
24
*
30
25
* @type {String }
31
26
*/
@@ -36,7 +31,7 @@ define([
36
31
* server (ICU Date Format).
37
32
*
38
33
* Used only in date picker mode
39
- * (this.showsTime == false).
34
+ * (this.options. showsTime == false).
40
35
*
41
36
* @type {String }
42
37
*/
@@ -48,7 +43,10 @@ define([
48
43
*
49
44
* @type {String }
50
45
*/
51
- datetimeFormat : '' ,
46
+ pickerDateTimeFormat : '' ,
47
+
48
+ pickerDefaultDateFormat : 'MM/dd/y' , // ICU Date Format
49
+ pickerDefaultTimeFormat : 'h:mm a' , // ICU Time Format
52
50
53
51
elementTmpl : 'ui/form/element/date' ,
54
52
@@ -75,13 +73,15 @@ define([
75
73
initConfig : function ( ) {
76
74
this . _super ( ) ;
77
75
78
- utils . extend ( this . options , {
79
- showsTime : this . showsTime ,
80
- timeFormat : this . timeFormat ,
81
- dateFormat : this . dateFormat
82
- } ) ;
76
+ if ( ! this . options . dateFormat ) {
77
+ this . options . dateFormat = this . pickerDefaultDateFormat ;
78
+ }
83
79
84
- this . prepareDatetimeFormats ( ) ;
80
+ if ( ! this . options . timeFormat ) {
81
+ this . options . timeFormat = this . pickerDefaultTimeFormat ;
82
+ }
83
+
84
+ this . prepareDateTimeFormats ( ) ;
85
85
86
86
return this ;
87
87
} ,
@@ -104,15 +104,15 @@ define([
104
104
shiftedValue ;
105
105
106
106
if ( value ) {
107
- if ( this . showsTime ) {
107
+ if ( this . options . showsTime ) {
108
108
shiftedValue = moment . utc ( value ) . add ( this . timeOffset , 'seconds' ) ;
109
109
} else {
110
110
dateFormat = this . shiftedValue ( ) ? this . outputDateFormat : this . inputDateFormat ;
111
111
112
112
shiftedValue = moment ( value , dateFormat ) ;
113
113
}
114
114
115
- shiftedValue = shiftedValue . format ( this . datetimeFormat ) ;
115
+ shiftedValue = shiftedValue . format ( this . pickerDateTimeFormat ) ;
116
116
117
117
if ( shiftedValue !== this . shiftedValue ( ) ) {
118
118
this . shiftedValue ( shiftedValue ) ;
@@ -130,11 +130,11 @@ define([
130
130
var value ;
131
131
132
132
if ( shiftedValue ) {
133
- if ( this . showsTime ) {
134
- value = moment . utc ( shiftedValue , this . datetimeFormat ) ;
133
+ if ( this . options . showsTime ) {
134
+ value = moment . utc ( shiftedValue , this . pickerDateTimeFormat ) ;
135
135
value = value . subtract ( this . timeOffset , 'seconds' ) . toISOString ( ) ;
136
136
} else {
137
- value = moment ( shiftedValue , this . datetimeFormat ) ;
137
+ value = moment ( shiftedValue , this . pickerDateTimeFormat ) ;
138
138
value = value . format ( this . outputDateFormat ) ;
139
139
}
140
140
@@ -148,16 +148,21 @@ define([
148
148
* Prepares and converts all date/time formats to be compatible
149
149
* with moment.js library.
150
150
*/
151
- prepareDatetimeFormats : function ( ) {
152
- this . datetimeFormat = this . dateFormat ;
151
+ prepareDateTimeFormats : function ( ) {
152
+ this . pickerDateTimeFormat = this . options . dateFormat ;
153
153
154
- if ( this . showsTime ) {
155
- this . datetimeFormat += ' ' + this . timeFormat ;
154
+ if ( this . options . showsTime ) {
155
+ this . pickerDateTimeFormat += ' ' + this . options . timeFormat ;
156
156
}
157
157
158
- this . datetimeFormat = utils . normalizeDate ( this . datetimeFormat ) ;
158
+ this . pickerDateTimeFormat = utils . normalizeDate ( this . pickerDateTimeFormat ) ;
159
+
160
+ if ( this . dateFormat ) {
161
+ this . inputDateFormat = this . dateFormat ;
162
+ }
159
163
160
164
this . inputDateFormat = utils . normalizeDate ( this . inputDateFormat ) ;
165
+
161
166
this . outputDateFormat = utils . normalizeDate ( this . outputDateFormat ) ;
162
167
}
163
168
} ) ;
0 commit comments