문제

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?

도움이 되었습니까?

해결책

Create a function that gets Date.Format and replaces yyyy with `yy`` and returns the result. Use that function instead of Date.Format

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top