时间段判断的问题,应该对高手不难,帮忙看看
一个小时内以分钟计算,58-10分 到上海 10-22分 到 北京 22-34 到广州 34-46 到香港 46-58 到台湾,我自己写了个,但是到了58-10会判断不出
if (StrToInt(FormatDateTime('n', Now)) >= 59-i) and (StrToInt(FormatDateTime('n', Now)) <= 11-i) then
begin Result:='上海'; exit; end;
if (StrToInt(FormatDateTime('n', Now)) >= 11-i) and (StrToInt(FormatDateTime('n', Now)) <= 23-i) then
begin Result:='北京'; exit; end;
if (StrToInt(FormatDateTime('n', Now)) >= 23-i) and (StrToInt(FormatDateTime('n', Now)) <= 35-i) then
begin Result:='广州'; exit; end;
if (StrToInt(FormatDateTime('n', Now)) >= 35-i) and (StrToInt(FormatDateTime('n', Now)) <= 47-i) then
begin Result:='香港'; exit; end;
if (StrToInt(FormatDateTime('n', Now)) >= 47-i) and (StrToInt(FormatDateTime('n', Now)) <= 59-i) then
begin Result:='台湾'; exit; end;
或者有没有更好更简介的代码来实现呢
[解决办法]
m:=StrToInt(FormatDateTime('n', Now));case m of58,59,0..10: Result:='上海';11..22: Result:='北京';23..34: Result:='广州';35..46: Result:='香港';47..57: Result:='台湾';end;