common.js
// formats dates using a custom format
formats dates using a custom format
formats dates using a custom format
function FormatDate(dt, format)
{
    var isLocal = true;
    if(format.lastIndexOf("[u]") != -1)
    {
        isLocal = false;
        format = format.replace("[u]", "");
    }
    format = format.replace("[yyyy]", (isLocal) ? dt.getFullYear() : dt.getUTCFullYear());
    format = format.replace("[yy]", (isLocal) ? (dt.getFullYear() + "").substr(2,2) : (dt.getUTCFullYear() + "").substr(2,2));
    format = format.replace("[mm]", (isLocal) ? PadZero(dt.getMonth() + 1) : PadZero(dt.getUTCMonth() + 1));
    format = format.replace("[m]", (isLocal) ? dt.getMonth() + 1 : dt.getUTCMonth() + 1);
    format = format.replace("[ddd]", (isLocal) ? GetDaySuffix(dt.getDate()) : GetDaySuffix(dt.getUTCDate()));
    format = format.replace("[dd]", (isLocal) ? PadZero(dt.getDate()) : PadZero(dt.getUTCDate()));
    format = format.replace("[d]", (isLocal) ? dt.getDate() : dt.getUTCDate());
    format = format.replace("[hh]", (isLocal) ? PadZero(dt.getHours()) : PadZero(dt.getUTCHours()));
    format = format.replace("[h]", (isLocal) ? dt.getHours() : dt.getUTCHours());
    format = format.replace("[12hh]", (isLocal) ? PadZero(Get12Hour(dt.getHours())) : PadZero(Get12Hour(dt.getUTCHours())));
    format = format.replace("[12h]", (isLocal) ? Get12Hour(dt.getHours()) : Get12Hour(dt.getUTCHours()));
    format = format.replace("[nn]", (isLocal) ? PadZero(dt.getMinutes()) : PadZero(dt.getUTCMinutes()));
    format = format.replace("[n]", (isLocal) ? dt.getMinutes() : dt.getUTCMinutes());
    format = format.replace("[ss]", (isLocal) ? PadZero(dt.getSeconds()) : PadZero(dt.getUTCSeconds()));
    format = format.replace("[s]", (isLocal) ? dt.getSeconds() : dt.getUTCSeconds());
    format = format.replace("[mmmm]", (isLocal) ? GetMonthName(dt.getMonth()) : GetMonthName(dt.getUTCMonth()));
    format = format.replace("[mmm]", (isLocal) ? GetMonthName(dt.getMonth()).substr(0,3) : GetMonthName(dt.getUTCMonth()).substr(0,3));
    format = format.replace("[ww]", (isLocal) ? GetWeekdayName(dt.getDay()) : GetWeekdayName(dt.getUTCDay()));
    format = format.replace("[w]", (isLocal) ? GetWeekdayName(dt.getDay()).substr(0,3) : GetWeekdayName(dt.getUTCDay()).substr(0,3));
    format = format.replace("[a]", (isLocal) ? (dt.getHours() > 12 ? "PM" : "AM") : (dt.getUTCHours() > 12 ? "PM" : "AM"));
    return format;
}
function FormatDate ( dt , format ) { var isLocal = true ; if ( format . lastIndexOf ( "[u]" ) != - 1 ) { isLocal = false ; format = format . replace ( "[u]" , "" ) ; } format = format . replace ( "[yyyy]" , ( isLocal ) ? dt . getFullYear ( ) : dt . getUTCFullYear ( ) ) ; format = format . replace ( "[yy]" , ( isLocal ) ? ( dt . getFullYear ( ) + "" ) . substr ( 2 , 2 ) : ( dt . getUTCFullYear ( ) + "" ) . substr ( 2 , 2 ) ) ; format = format . replace ( "[mm]" , ( isLocal ) ? PadZero ( dt . getMonth ( ) + 1 ) : PadZero ( dt . getUTCMonth ( ) + 1 ) ) ; format = format . replace ( "[m]" , ( isLocal ) ? dt . getMonth ( ) + 1 : dt . getUTCMonth ( ) + 1 ) ; format = format . replace ( "[ddd]" , ( isLocal ) ? GetDaySuffix ( dt . getDate ( ) ) : GetDaySuffix ( dt . getUTCDate ( ) ) ) ; format = format . replace ( "[dd]" , ( isLocal ) ? PadZero ( dt . getDate ( ) ) : PadZero ( dt . getUTCDate ( ) ) ) ; format = format . replace ( "[d]" , ( isLocal ) ? dt . getDate ( ) : dt . getUTCDate ( ) ) ; format = format . replace ( "[hh]" , ( isLocal ) ? PadZero ( dt . getHours ( ) ) : PadZero ( dt . getUTCHours ( ) ) ) ; format = format . replace ( "[h]" , ( isLocal ) ? dt . getHours ( ) : dt . getUTCHours ( ) ) ; format = format . replace ( "[12hh]" , ( isLocal ) ? PadZero ( Get12Hour ( dt . getHours ( ) ) ) : PadZero ( Get12Hour ( dt . getUTCHours ( ) ) ) ) ; format = format . replace ( "[12h]" , ( isLocal ) ? Get12Hour ( dt . getHours ( ) ) : Get12Hour ( dt . getUTCHours ( ) ) ) ; format = format . replace ( "[nn]" , ( isLocal ) ? PadZero ( dt . getMinutes ( ) ) : PadZero ( dt . getUTCMinutes ( ) ) ) ; format = format . replace ( "[n]" , ( isLocal ) ? dt . getMinutes ( ) : dt . getUTCMinutes ( ) ) ; format = format . replace ( "[ss]" , ( isLocal ) ? PadZero ( dt . getSeconds ( ) ) : PadZero ( dt . getUTCSeconds ( ) ) ) ; format = format . replace ( "[s]" , ( isLocal ) ? dt . getSeconds ( ) : dt . getUTCSeconds ( ) ) ; format = format . replace ( "[mmmm]" , ( isLocal ) ? GetMonthName ( dt . getMonth ( ) ) : GetMonthName ( dt . getUTCMonth ( ) ) ) ; format = format . replace ( "[mmm]" , ( isLocal ) ? GetMonthName ( dt . getMonth ( ) ) . substr ( 0 , 3 ) : GetMonthName ( dt . getUTCMonth ( ) ) . substr ( 0 , 3 ) ) ; format = format . replace ( "[ww]" , ( isLocal ) ? GetWeekdayName ( dt . getDay ( ) ) : GetWeekdayName ( dt . getUTCDay ( ) ) ) ; format = format . replace ( "[w]" , ( isLocal ) ? GetWeekdayName ( dt . getDay ( ) ) . substr ( 0 , 3 ) : GetWeekdayName ( dt . getUTCDay ( ) ) . substr ( 0 , 3 ) ) ; format = format . replace ( "[a]" , ( isLocal ) ? ( dt . getHours ( ) > 12 ? "PM" : "AM" ) : ( dt . getUTCHours ( ) > 12 ? "PM" : "AM" ) ) ; return format ; }
formats dates using a custom format
formats dates using a custom format