将阿拉伯数字日期转换为中文数字日期格式(ASP)

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

刚才看到一个兄弟提的问题,做完了才发现已经结贴,郁闷呀~~

只是看到这个东西还算有用,所以贴出来自赏呵呵

思路:

一开始想到用select,用for循环将每位阿拉伯数字转换成对应的中文,然后想到其实可以用数组,这样子比较少些代码,毕竟0~9,可以对应起来,可是~问题出现了,对于10~31,要变成“贰拾壹” 这样格式,呵呵~加一个判断,嗯~11可不能转换成“壹拾壹”,在加判断

呵呵~基本好了,还需要判断是不是数字呢,ok!这下子应该是可以over了!

<%

t=Now()

Function datetostr(t)

Dim strYear,strMonth,strDay,strResult

strYear = Year(t)

strMonth = Month(t)

strDay = Day(t)

datetostr = casei(strYear) & "年" & casei(strMonth) & "月" & casei(strDay) & "日"

End Function

Function casei(i)

Dim arrNum,arrCNNum

If(IsNumeric(i))Then

arrNum = Split(i)

arrCNNum=Split("零,壹,贰,叁,肆,伍,陆,柒,捌,玖",",")

If( i<10 OR i>31)Then

For it=1 To Len(i)

strResult = strResult & arrCNNum(CInt(Mid(i,it,1)))

Next

ElseIf(i > 9 AND i < 12)Then

strResult = "拾" & arrCNNum(CInt(Mid(i,2,1)))

Else

strResult = arrCNNum(CInt(Mid(i,1,1))) & "拾" & arrCNNum(CInt(Mid(i,2,1)))

End If

End If

casei = strResult

End Function

Response.Write(datetostr(t))

%>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航