@@ -61,12 +61,13 @@ var widget = $.widget( "ui.datepicker", {
61
61
62
62
_create : function ( ) {
63
63
this . suppressExpandOnFocus = false ;
64
+ this . _parse = new Globalize ( this . options . locale ) . dateParser ( this . options . dateFormat ) ;
64
65
65
66
if ( $ . type ( this . options . max ) === "string" ) {
66
- this . options . max = Globalize . parseDate ( this . options . max , { raw : "yyyy-MM-dd" } ) ;
67
+ this . options . max = this . _parse ( this . options . max ) ;
67
68
}
68
69
if ( $ . type ( this . options . min ) === "string" ) {
69
- this . options . min = Globalize . parseDate ( this . options . min , { raw : "yyyy-MM-dd" } ) ;
70
+ this . options . min = this . _parse ( this . options . min ) ;
70
71
}
71
72
72
73
this . _createCalendar ( ) ;
@@ -79,30 +80,30 @@ var widget = $.widget( "ui.datepicker", {
79
80
_getCreateOptions : function ( ) {
80
81
var max = this . element . attr ( "max" ) ,
81
82
min = this . element . attr ( "min" ) ,
83
+ parser = new Globalize ( "en" ) . dateParser ( { raw : "yyyy-MM-dd" } ) ,
82
84
options = { } ;
83
85
84
86
if ( max !== undefined ) {
85
- options . max = Globalize . parseDate ( max , { raw : "yyyy-MM-dd" } ) ;
87
+ options . max = parser ( max ) ;
86
88
}
87
89
88
90
if ( min !== undefined ) {
89
- options . min = Globalize . parseDate ( min , { raw : "yyyy-MM-dd" } ) ;
91
+ options . min = parser ( min ) ;
90
92
}
91
93
92
94
return options ;
93
95
} ,
94
96
95
97
_createCalendar : function ( ) {
96
- var that = this ,
97
- globalize = new Globalize ( this . options . locale ) ;
98
+ var that = this ;
98
99
99
100
this . calendar = $ ( "<div>" ) . appendTo ( this . _appendTo ( ) ) ;
100
101
this . _addClass ( this . calendar , "ui-datepicker" , "ui-front" ) ;
101
102
102
103
// Initialize calendar widget
103
104
this . calendarInstance = this . calendar
104
105
. calendar ( $ . extend ( { } , this . options , {
105
- value : globalize . dateParser ( this . options . dateFormat ) ( this . element . val ( ) ) ,
106
+ value : this . _parse ( this . element . val ( ) ) ,
106
107
select : function ( event ) {
107
108
that . element . val ( that . calendarInstance . value ( ) ) ;
108
109
that . close ( ) ;
@@ -118,7 +119,6 @@ var widget = $.widget( "ui.datepicker", {
118
119
this . calendarInstance . buttonClickContext = that . element [ 0 ] ;
119
120
120
121
this . _setHiddenPicker ( ) ;
121
-
122
122
this . element . attr ( {
123
123
"aria-haspopup" : true ,
124
124
"aria-owns" : this . calendar . attr ( "id" )
@@ -302,7 +302,7 @@ var widget = $.widget( "ui.datepicker", {
302
302
303
303
value : function ( value ) {
304
304
if ( arguments . length ) {
305
- this . valueAsDate ( this . calendarInstance . _parse ( value ) ) ;
305
+ this . valueAsDate ( this . _parse ( value ) ) ;
306
306
} else {
307
307
return this . _getParsedValue ( ) ? this . element . val ( ) : null ;
308
308
}
@@ -334,10 +334,16 @@ var widget = $.widget( "ui.datepicker", {
334
334
} ,
335
335
336
336
_getParsedValue : function ( ) {
337
- return this . calendarInstance . _parse ( this . element . val ( ) ) ;
337
+ return this . _parse ( this . element . val ( ) ) ;
338
338
} ,
339
339
340
340
_setOption : function ( key , value ) {
341
+ if ( key === "max" || key === "min" ) {
342
+ if ( typeof value === "string" ) {
343
+ value = this . _parse ( value ) ;
344
+ }
345
+ }
346
+
341
347
this . _super ( key , value ) ;
342
348
343
349
if ( $ . inArray ( key , this . calendarOptions ) !== - 1 ) {
0 commit comments