jalali-moment.js
function toJalaliFormat(format) {
    for (var i = 0; i < format.length; i++) {
        if(!i || (format[i-1] !== "j" && format[i-1] !== format[i])) {
            if (format[i] === "Y" || format[i] === "M" || format[i] === "D" || format[i] === "g") {
                format = format.slice(0, i) + "j" + format.slice(i);
            }
        }
    }
    return format;
}
function toJalaliFormat(format) {
    for (var i = 0; i < format.length; i++) {
        if(!i || (format[i-1] !== "j" && format[i-1] !== format[i])) {
            if (format[i] === "Y" || format[i] === "M" || format[i] === "D" || format[i] === "g") {
                format = format.slice(0, i) + "j" + format.slice(i);
            }
        }
    }
    return format;
}
function toJalaliFormat ( format ) { for ( var i = 0 ; i < format . length ; i ++ ) { if ( ! i || ( format [ i - 1 ] !== "j" && format [ i - 1 ] !== format [ i ] ) ) { if ( format [ i ] === "Y" || format [ i ] === "M" || format [ i ] === "D" || format [ i ] === "g" ) { format = format . slice ( 0 , i ) + "j" + format . slice ( i ) ; } } } return format ; }
Changes any moment Gregorian format to Jalali system format
@param {string} format
@example toJalaliFormat("YYYY/MMM/DD") => "jYYYY/jMMM/jDD"
Changes any moment Gregorian format to Jalali system format