Chinese character script>
/*
Function: YYYY-MM-DD digital date into Chinese characters
Example: 1984-3-7-> March 7, 1984
Call: Baodate2chinese ("1984-3-7")
*/
var Chinese = [' 0 ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six ', ' seven ', ' eight ', ' nine '];
var len = [' Ten '];
var ydm =[' year ', ' Month ', ' Day '];
function Num2chinese (s)
{
file://converts a single number into Chinese.
S= "" +s;
Slen = s.length;
var result= "";
for (Var i=0;i<slen;i++)
{
Result+=chinese[s.charat (i)];
}
return result;
}
function n2c (s)
{
file://toSpecial cases are handled.
S= "" +s;
var result= "";
if (s.length==2)
{
if (S.charat (0) = = "1")
{
if (S.charat (1) = = "0") return len[0];
return Len[0]+chinese[s.charat (1)];
}
if (S.charat (1) = = "0") return Chinese[s.charat (0)]+len[0];
Return Chinese[s.charat (0)]+len[0]+chinese[s.charat (1)];
}
return Num2chinese (s)
}
function Baodate2chinese (s)
{
file://InspectionEnter the date format. And extract the relevant numbers.
var Datepat =/^ (\d{2}|\d{4}) (\/|-) (\d{1,2}) (\2) (\d{1,2}) $/;
var Matcharray = S.match (Datepat);
var ok= "";
if (Matcharray = null) return false;
for (Var i=1;i<matcharray.length;i=i+2)
{
OK+=N2C (matcharray[i]-0) +ydm[(i-1)/2];
}
return OK;
}
</script>
Yyyy-mm-dd:<input type=text name= "mydate" value= "1984-3-7" >
Chinese display: <input type=text name= "Okdate" >
<input Type=button
Value= "Convert" >