文章目录
提示:以下是本篇文章正文内容,下面案例可供参考
代码如下(示例):
function TFhsgzz_brrk.DateToCapital(datetime: TDateTime): string;
const
Capital: array[0..9] of string = ('零', '一', '二', '三', '四', '五', '六', '七', '八', '九');
mCapital: array[0..5] of string = ('零', '十', '二十', '三十', '四十', '五十');
var
tmp: string;
function DivideByZero(s: string): string;
var
x: integer;
begin
Result := '';
try
x := strtoint(s);
if x > 9 then
begin
if s[1] <> '0' then
Result := mCapital[strtoint(s[1])];
if s[2] <> '0' then
Result := Result + Capital[strtoint(s[2])];
end
else
begin
Result := Result + Capital[strtoint(s[2])];
end;
except
end;
end;
begin
Result := '';
if datetime = null then
exit;
tmp := formatdatetime('yyyymmddhhnnss', datetime);
Result := Capital[strtoint(tmp[1])] + Capital[strtoint(tmp[2])] + Capital[strtoint(tmp[3])] + Capital[strtoint(tmp[4])] + '年';
Result := Result + DivideByZero(tmp[5] + tmp[6]);
Result := Result + '月';
Result := Result + DivideByZero(tmp[7] + tmp[8]);
Result := Result + '日';
Result := Result + DivideByZero(tmp[9] + tmp[10]);
Result := Result + '时';
Result := Result + DivideByZero(tmp[11] + tmp[12]);
Result := Result + '分';
Result := Result + DivideByZero(tmp[13] + tmp[14]) + '秒';
end;
调用:
ShowMessage(DateToCapital(now));