var
SectionOneStart,SectionOneEnd:string;
TempCurrentDateTime:TTime;
begin
SectionOneStart:='8:00:00';
SectionOneEnd:='12:00:00';
TempCurrentDateTime:=Now();
if (StrToTime(SectionOneStart)< TempCurrentDateTime) then
showmessage(timetostr(TempCurrentDateTime)+' '+SectionOneStart);
if StrToTime(SectionOneEnd)<TempCurrentDateTime then
showmessage(timetostr(TempCurrentDateTime)+' '+SectionOneEnd);
把机器时间跳到8:00-12:00之间,告诉我什么结果
SectionOneStart,SectionOneEnd:string;
TempCurrentDateTime:TTime;
begin
SectionOneStart:='8:00:00';
SectionOneEnd:='12:00:00';
TempCurrentDateTime:=Now();
if (StrToTime(SectionOneStart)< TempCurrentDateTime) then
showmessage(timetostr(TempCurrentDateTime)+' '+SectionOneStart);
if StrToTime(SectionOneEnd)<TempCurrentDateTime then
showmessage(timetostr(TempCurrentDateTime)+' '+SectionOneEnd);
把机器时间跳到8:00-12:00之间,告诉我什么结果
t := StrToTime(SectionOneEnd);
ATime: TDateTime;
begin
ATime := StrToTime(Edit1.Text);
if ATime < 0.50 then
ShowMessage('Good Morning')
else
ShowMessage('Good Afternoon');
end;
//所以当只能时间赋值之后,因为没有日期部分,即整数部分为零,
//那么也就是1899年12月30日的时间,当然与当前日期时间比较会有意想不到的结果。
//所以在楼主的应用应当用当前的日期才是,故而应该加上取当前日期再加上时间。
//TmpDateTime:=Int(Now())+StrToTime('08:00:00');var
SectionOneStart,SectionOneEnd:string;
TempCurrentDateTime:TTime;
begin
SectionOneStart:='8:00:00';
SectionOneEnd:='12:00:00';
TempCurrentDateTime:=Now();
//if (StrToTime(SectionOneStart)< TempCurrentDateTime) then
if ((StrToTime(SectionOneStart)+Int(TempCurrentDateTime){取整数部分,即日期})< TempCurrentDateTime) then
showmessage(timetostr(TempCurrentDateTime)+' '+SectionOneStart);
//if StrToTime(SectionOneEnd)<TempCurrentDateTime then
if (StrToTime(SectionOneEnd)+Int(TempCurrentDateTime))<TempCurrentDateTime then
showmessage(timetostr(TempCurrentDateTime)+' '+SectionOneEnd);