日期转中文

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;
}

你可能感兴趣的:(日期)