首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

日期转汉语言

2012-08-30 
日期转中文function convertDate(){??? var frmdocument.EditForm??? ??? var outputCharacters???

日期转中文

function convertDate(){
??? var frm=document.EditForm;???
??? var outputCharacters='';
??? var cur=trim(frm["record.decDate"].value);
??? if (cur!=''){
??? ??? parts = cur.split("-");
??? ??? if (parts.length > 1) {?
??? ??? ?var year = parts[0];?
??? ??? ?var month = parts[1];?
??? ??? ?var day=parts[2];
??? ??? ?for (i = 0; i < year.length; i++) {?
??? ??? ??? ?outputCharacters+=numYear1(year.substr(i, 1));
??? ??? ?}
??? ??? ?outputCharacters+="年";
??? ??? ?outputCharacters+=number1(month)+"月";
??? ??? ?outputCharacters+=number1(day)+"日";
??? ??? }?
??? }
???? frm["decStrDate"].value=outputCharacters;?
???
}

?

function number(index1){
? var str='';
? var numberstring="壹贰叁肆伍陆柒捌玖拾";
? if(index1 ==0) {str="拾";}
? if(index1 < 10){
??? str=numberstring.substring(0+(index1-1),index1)}
? else if(index1 < 20 ){
?? str="拾"+numberstring.substring(0+(index1-11),(index1-10))}
? else if(index1 < 30 ){
?? str="贰拾"+numberstring.substring(0+(index1-21),(index1-20))}
? else{
?? str="叁拾"+numberstring.substring(0+(index1-31),(index1-30))}
? return str;
}

function numYear(index1){
??? if (index1==0) return "零";
??? var numberstring="壹贰叁肆伍陆柒捌玖拾";
??? return numberstring.substring(0+(index1-1),index1)???
}

function number1(index1){
? var str='';
? var numberstring="一二三四五六七八九十";
? if(index1 ==0) {str="十";}
? if(index1 < 10){
??? str=numberstring.substring(0+(index1-1),index1)}
? else if(index1 < 20 ){
?? str="十"+numberstring.substring(0+(index1-11),(index1-10))}
? else if(index1 < 30 ){
?? str="二十"+numberstring.substring(0+(index1-21),(index1-20))}
? else{
?? str="三十"+numberstring.substring(0+(index1-31),(index1-30))}
? return str;
}

热点排行