本函数原为VFP中取日期转中文日期方式,后增加日期时间处理,并改用Iif及ICase修改原代码。
Function DateTime2CHN
Parameters pdDate,plTime
*!* pdDate -- 日期 或 日期时间; plTime -- 取时间否,1--取时间,0--不取时间(默认),此参数为空时取默认值
*!* By HeQiang 2003-04-01 Edit:2010-07-12
If VarType(plTime, .T.)<>'N' Or IsNull(plTime) Or !Between(plTime, 0, 1) Or VarType(pdDate,.T.)='D'
plTime = 0
EndIf
Local lcYMD
Local lnYear,lnMonth,lnDay
lnYear = Year(pdDate)
lnMonth = Month(pdDate)
lnDay = Day(pdDate)

lcYMD = ChrTranC(Transform(lnYear), [1234567890], [一二三四五六七八九〇]) + [年]
lcYMD = lcYMD + ChrTranC(ICase(lnMonth>9, [十] + Transform(Mod(lnMonth,10)), Transform(lnMonth)), [1234567890], [一二三四五六七八九]) + [月]
lcYMD = lcYMD + ChrTranC(ICase(lnDay>19, Transform(Int(lnDay/10)) + [十] + Transform(Mod(lnDay,10)), lnDay>9, [十] + Transform(Mod(lnDay,10)), Transform(lnDay)), [1234567890], [一二三四五六七八九]) + [日]
If plTime=0
Else
lcYMD = lcYMD + [ ] + Iif(Hour(ldDate)=0, [〇], ChrTranC(ICase(Hour(ldDate)>19, Transform(Int(Hour(ldDate)/10)) + [十] + Transform(Mod(Hour(ldDate),10)), Hour(ldDate)>9, [十] + Transform(Mod(Hour(ldDate),10)), Transform(Hour(ldDate))), [1234567890], [一二三四五六七八九])) + [时]
lcYMD = lcYMD + Iif(Minute(ldDate)=0, [〇], ChrTranC(ICase(Minute(ldDate)>19, Transform(Int(Minute(ldDate)/10)) + [十] + Transform(Mod(Minute(ldDate),10)), Minute(ldDate)>9, [十] + Transform(Mod(Minute(ldDate),10)), Transform(Minute(ldDate))),[1234567890], [一二三四五六七八九])) + [分]
lcYMD = lcYMD + Iif(Sec(ldDate)=0, [〇], ChrTranC(ICase(Sec(ldDate)>19, Transform(Int(Sec(ldDate)/10)) + [十] + Transform(Mod(Sec(ldDate),10)), Sec(ldDate)>9, [十] + Transform(Mod(Sec(ldDate),10)), Transform(Sec(ldDate))), [1234567890], [一二三四五六七八九])) + [秒]
EndIf
Return lcYMD
EndFunc

05-16 06:03