Handle negative time spans

前端 未结 9 601
不知归路
不知归路 2020-12-30 18:50

In my output of a grid, I calculate a TimeSpan and take its TotalHours. e.g.

(Eval(\"WorkedHours\") - Eval(\"BadgedHours\")).TotalH         


        
9条回答
  •  抹茶落季
    2020-12-30 19:38

    The simple solution would be to do:

    string format = "HH:mm";
    if(hours < 0)
      format = "-" + format;
    
    hours = Math.Abs(hours)
    

提交回复
热议问题