Value := formatThaiDate('dd/mm/eeee',date);
function FormatThaiDate(options: string; FDate: TdateTime): string;
var
sd: string;
opt: string;
begin
if (options = 'ddmmyy') then
result := formatdatetime('dd', fdate) +
formatdatetime('mm', fdate) +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'yymmdd' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
+
formatdatetime('mm', fdate) + formatdatetime('dd', fdate)
else if options = 'dd/mm/yy' then
result := formatdatetime('dd', fdate) + '/' +
formatdatetime('mm', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'dd/mm/ee' then
result := formatdatetime('dd', fdate) + '/' +
formatdatetime('mm', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'dd/mm/yyyy' then
result := formatdatetime('dd', fdate) + '/' +
formatdatetime('mm', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 1, 4)
else if options = 'dd/mm/yyyy hh:nn:ss' then
result := formatdatetime('dd', fdate) + '/' +
formatdatetime('mm', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 1, 4) + ' '
+
formatdatetime('hh:nn:ss', fdate)
else if options = 'yy-mm-dd hh:nn:ss.zzz' then
result := formatdatetime('yy-mm-dd hh:nn:ss.zzz', fdate)
else if options = 'dd-mm-yyyy' then
result := formatdatetime('dd', fdate) + '-' +
formatdatetime('mm', fdate) + '-' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 1, 4)
else if options = 'd/m/yyyy' then
result := formatdatetime('d', fdate) + '/' +
formatdatetime('m', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 1, 4)
else if options = 'dd mmmm yyyy' then
result := formatdatetime('dd', fdate) + ' ' +
formatdatetime('mmmm', fdate) + ' ' +
inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if options = 'd m yyyy' then
result := formatdatetime('d', fdate) + ' ' +
formatdatetime('m', fdate) + ' ' +
inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if options = 'd mmmm yyyy' then
result := formatdatetime('d', fdate) + ' ' +
formatdatetime('mmmm', fdate) + ' ' +
inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if options = 'd mmm yy' then
result := formatdatetime('d', fdate) + ' ' +
formatdatetime('mmm', fdate) + ' ' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'd mmmm yy' then
result := formatdatetime('d', fdate) + ' ' +
formatdatetime('mmmm', fdate) + ' ' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'mmmm yyyy' then
result := formatdatetime('mmmm', fdate) + ' ' +
inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if options = 'd mmm yyyy' then
result := formatdatetime('d', fdate) + ' ' +
formatdatetime('mmm', fdate) + ' ' +
inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if options = 'yyyy' then
result := inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if options = 'yy/mm/dd' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
+
'/' + formatdatetime('mm', fdate) + '/' + formatdatetime('dd', fdate)
else if options = 'mm/yy' then
result := formatdatetime('mm', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'yy/mm' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
+
'/' + formatdatetime('mm', fdate)
else if options = 'ee' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'mmyy' then
result :=
formatdatetime('mm', fdate) +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'mm/ee' then
result :=
formatdatetime('mm', fdate) + '/' +
copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'yymm' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
+
formatdatetime('mm', fdate)
else if options = 'yy' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'mm' then
result := formatdatetime('mm', fdate)
else if options = 'yy' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'ee' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
else if options = 'eemmddhhnnss' then
result := copy(inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543), 3, 2)
+
formatdatetime('mmddhhnnss', fdate)
else if options = 'mm' then
result := formatdatetime('mm', fdate)
else if options = 'eeee' then
result := inttostr(strtoint(formatdatetime('yyyy', fdate)) + 543)
else if pos('ee', options) = 0 then
begin
if pos('yyyy', options) > 0 then
begin
sd := formatthaidate('eeee', fdate);
opt := replacestr(options, 'yyyy', sd);
result := sysutils.formatdatetime(opt, fdate);
end
else if pos('yy', options) > 0 then
begin
sd := formatthaidate('ee', fdate);
opt := replacestr(options, 'yy', sd);
result := sysutils.formatdatetime(opt, fdate);
end
else if pos('ee', options) > 0 then
begin
if pos('eeee', options) > 0 then
begin
sd := formatthaidate('eeee', fdate);
opt := replacestr(options, 'eeee', sd);
end
else
begin
sd := formatthaidate('ee', fdate);
opt := replacestr(options, 'ee', sd);
end;
result := sysutils.formatdatetime(opt, fdate);
end
else
begin
result := sysutils.formatdatetime(options, fdate);
end;
//result := formatdatetime(options, fdate);
end
else
Messagedlg('Options not found for Format Thaidate function ! ' + options,
mterror, [mbok], 0);
end;