@@ -25,7 +25,7 @@ export default Ember.Mixin.create({
2525 enableOnReadonly : this . get ( 'enableOnReadonly' ) ,
2626 endDate : this . get ( 'endDate' ) ,
2727 forceParse : this . get ( 'forceParse' ) ,
28- format : this . get ( 'format' ) ,
28+ format : this . _toString ( this . get ( 'format' ) ) ,
2929 immediateUpdates : this . get ( 'immediateUpdates' ) ,
3030 keyboardNavigation : this . get ( 'keyboardNavigation' ) ,
3131 language : this . get ( 'language' ) || undefined ,
@@ -113,8 +113,9 @@ export default Ember.Mixin.create({
113113 } ) ;
114114
115115 this . addObserver ( 'format' , function ( ) {
116- this . $ ( ) . datepicker ( 'format' , this . get ( 'format' ) ) ;
117- this . $ ( ) . data ( 'datepicker' ) . _process_options ( { format : this . get ( 'format' ) } ) ;
116+ let format = this . _toString ( this . get ( 'format' ) ) ;
117+ this . $ ( ) . datepicker ( 'format' , format ) ;
118+ this . $ ( ) . data ( 'datepicker' ) . _process_options ( { format : format } ) ;
118119 this . _updateDatepicker ( ) ;
119120 } ) ;
120121 } ) ,
@@ -160,5 +161,23 @@ export default Ember.Mixin.create({
160161 clone . setMilliseconds ( 0 ) ;
161162
162163 return clone ;
164+ } ,
165+
166+ /**
167+ * Fix Issue #59
168+ * _toString Checks and converts the input object and returns a String if it is required and feasible
169+ * @param {Object } obj The object to check
170+ * @return {Object } The object as a String
171+ */
172+ _toString : function ( obj ) {
173+ if ( typeof obj !== typeof Undefined && obj !== typeof String ) {
174+ if ( typeof obj . toString === typeof Function ) {
175+ obj = obj . toString ( ) ;
176+ } else {
177+ // No toString() method available - There is nothing else that can be done
178+ throw new Error ( "At _toString() (datepicker-support.js) - No toString() method available for the passed object." ) ;
179+ }
180+ }
181+ return obj ;
163182 }
164183} ) ;
0 commit comments