Reputation: 3848
Here is my javascript snippet for date picker
jQuery.fn.dateWidget = function(settings){
// default settings
defaults = {
changeMonth: true,
changeYear: true,
dateFormat: Date.format,
duration: '',
showOn: 'button',
showAnim: '',
buttonText: Resources['common.button.selectdate'],
buttonImage: Resources['appUrl'] + 'core/images/datePicker.gif',
buttonImageOnly: true
};
// overwrite the defaults with provided settings
settings = $.extend(defaults, settings);
return this.each(function(){
$(this).datepicker(settings);
});
};
Our application is localized and the Date.Format value is set from a properties file. It works perfectly but whenever a date format contains yyyy its generating year twice like 20142014-05-02 if date format is yyyy-mm-dd(swedish locale date format).
For yy-mm-dd dateformat datepicker gives 2014-05-02 but it breaks our application in other areas.
Am new to javascript, I dont really have any idea how to fix this. Could anyone help me to fix this?
Upvotes: 0
Views: 428
Reputation: 646
Create a function that gets Date.Format and replaces yyyy
with `yy`` and returns the result. Use that function instead of Date.Format
Upvotes: 1