首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

时间段判断的有关问题,应该对高手不难,帮忙看看

2012-03-30 
时间段判断的问题,应该对高手不难,帮忙看看一个小时内以分钟计算,58-10分 到上海10-22分 到 北京 22-34 到

时间段判断的问题,应该对高手不难,帮忙看看
一个小时内以分钟计算,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;

或者有没有更好更简介的代码来实现呢

[解决办法]

Delphi(Pascal) code
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; 

热点排行