日期转换为大写

2023-05-07 综合 35阅读
将年份、月份、日期分别转换成单个的数字字符,再孙丛悔转换成相应的大写,再合成。
将下列程序存为xxtodx.prg
调用时xxtodx(express)

PARAMETERS rq
SET date to ymd
SET MARK to "-"
yearsz=YEAR(rq)
yearc=STR(yearsz,4)
yearc1=SUBSTR(yearc,1,1)
yearc2=SUBSTR(yearc,2,1)
yearc3=SUBSTR(yearc,3,1)
yearc4=SUBSTR(yearc,4,1)

monthsz=MONTH(rq)
monthc=STR(monthsz,2)
monthc1=SUBSTR(monthc,1,1)
monthc2=SUBSTR(monthc,2,1)

daysz=DAY(rq)
dayc=STR(daysz,2)
dayc1=SUBSTR(dayc,1,1)
dayc2=SUBSTR(dayc,2,1)

yearzf=szzh(yearc1)+szzh(yearc2)+szzh(yearc3)+szzh(yearc4)

DO case
case monthsz<10
monthzf=szzh(monthc2)
CASE monthsz=10
monthzf="十"
CASE monthsz>10
monthzf="十"+szzh(monthc2)
ENDCASE

DO case
case daysz<10
dayzf=szzh(dayc2)
CASE daysz=10
dayzf="十"
CASE daysz>10.and.daysz<20
dayzf="十"+szzh(dayc2)
CASE daysz=20 .or.daysz=30
dayzf=szzh(dayc1)+"郑亮十"
CASE daysz>20
dayzf=szzh(dayc1)+"十"+szzh(dayc2)
ENDCASE

RETURN yearzf+"年"+monthzf+"月"+dayzf+"日"

PROCEDURE szzh (szzf)
DO case
CASE szzf="0"
RETURN "○"
CASE szzf="1"
RETURN "一则正"
CASE szzf="2"
RETURN "二"
CASE szzf="3"
RETURN "三"
CASE szzf="4"
RETURN "四"
CASE szzf="5"
RETURN "五"
CASE szzf="6"
RETURN "六"
CASE szzf="7"
RETURN "七"
CASE szzf="8"
RETURN "八"
CASE szzf="9"
RETURN "九"
ENDCASE
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com