X
xuaner
Unregistered / Unconfirmed
GUEST, unregistred user!
以下这个函数在自己的机器上没什么问题,但一到客户端就显示:'6:'不是一个整数。
我想是因为在我这台机上的日期格式和客户端上的日期格式不一样才导致取出的字符串
一个是06 一个是6:,我没有设定过日期格式,该怎样设定?[!]
function getdatetime(a:integer):tdatetime;
type
tdaterec=record
year:integer;
month:1..12;
day:1..31;
hour:0..23;
minute:0..59;
mm:0..100;
end;
var
s:string;
date1:tdaterec;
r:tdatetime;
begin
date1.year:=toint(copy(datetimetostr(now),1,4));
date1.month:=toint(copy(datetimetostr(now),6,2));
// strtoint(copy(datetimetostr(now),12,2))+(a mod 24)
if a>=24 then begin
date1.day:=toint(copy(datetimetostr(now),9,2))+(a div 24);
if (toint(copy(datetimetostr(now),12,2))+(a mod 24))>=24 then
begin
date1.day:=date1.day+1;
date1.hour:=toint(copy(datetimetostr(now),12,2))+(a mod 24)-24;
end else
date1.hour:=toint(copy(datetimetostr(now),12,2))+(a mod 24);
end
else
if (strtoint(copy(datetimetostr(now),12,2))+a) >=24
then begin
date1.day:=toint(copy(datetimetostr(now),9,2))+1;
date1.hour:=toint(copy(datetimetostr(now),12,2))+a-24;
end
else begin
date1.day:=toint(copy(datetimetostr(now),9,2));
date1.hour:=toint(copy(datetimetostr(now),12,2))+a;
end;
date1.minute:=toint(copy(datetimetostr(now),15,2));
date1.mm:=toint(copy(datetimetostr(now),18,2));
with date1 do
begin
s:=trim(inttostr(year))+'-'+trim(inttostr(month))+'-'+trim(inttostr(day))
+' '+trim(inttostr(hour))+':'+trim(inttostr(minute))+':'+
trim(inttostr(mm));
r:=strtodatetime(s);
end;
result:=r;
end;
我想是因为在我这台机上的日期格式和客户端上的日期格式不一样才导致取出的字符串
一个是06 一个是6:,我没有设定过日期格式,该怎样设定?[!]
function getdatetime(a:integer):tdatetime;
type
tdaterec=record
year:integer;
month:1..12;
day:1..31;
hour:0..23;
minute:0..59;
mm:0..100;
end;
var
s:string;
date1:tdaterec;
r:tdatetime;
begin
date1.year:=toint(copy(datetimetostr(now),1,4));
date1.month:=toint(copy(datetimetostr(now),6,2));
// strtoint(copy(datetimetostr(now),12,2))+(a mod 24)
if a>=24 then begin
date1.day:=toint(copy(datetimetostr(now),9,2))+(a div 24);
if (toint(copy(datetimetostr(now),12,2))+(a mod 24))>=24 then
begin
date1.day:=date1.day+1;
date1.hour:=toint(copy(datetimetostr(now),12,2))+(a mod 24)-24;
end else
date1.hour:=toint(copy(datetimetostr(now),12,2))+(a mod 24);
end
else
if (strtoint(copy(datetimetostr(now),12,2))+a) >=24
then begin
date1.day:=toint(copy(datetimetostr(now),9,2))+1;
date1.hour:=toint(copy(datetimetostr(now),12,2))+a-24;
end
else begin
date1.day:=toint(copy(datetimetostr(now),9,2));
date1.hour:=toint(copy(datetimetostr(now),12,2))+a;
end;
date1.minute:=toint(copy(datetimetostr(now),15,2));
date1.mm:=toint(copy(datetimetostr(now),18,2));
with date1 do
begin
s:=trim(inttostr(year))+'-'+trim(inttostr(month))+'-'+trim(inttostr(day))
+' '+trim(inttostr(hour))+':'+trim(inttostr(minute))+':'+
trim(inttostr(mm));
r:=strtodatetime(s);
end;
result:=r;
end;