Monday, November 29, 2010

Javascript to Numeric or to TimeString simple

__ToNumeric=function(s){
        var i=0;
        do{
            var c = s.charAt(i);
            if(c=='0')i++;else break;
        }while(i<s.length);
        if(i==s.length)return 0;
        return parseInt(i==0?s:s.substr(i,s.length-i));
    }

    __ToTimeStr=function(n){
        var v=n+'';
        return (v.length==1?'0'+v:v);
    }

No comments: