나는 시간, 분 초를 얻기 위해 기본 함수를 사용하고있다. 시간이 24 시간 미만이면 모든 것이 작동합니다. 24 시간이 아니더라도 몇 시간을 보내고 싶습니다.이 datetime 메서드가 실패하는 이유는 무엇입니까?
folowing 예를 아래 생산 : 00H : 00m : 00 년대
내 시험 :
[TestMethod()]
public void Test_Hours_Greater_Than_24()
{
EmployeeSkill target = new EmployeeSkill(); appropriate value
double sec = 86400;
string expected = "24h:00m:00s";
string actual;
actual = target.GetAgentTime(sec);
Assert.AreEqual(expected, actual);
}
내 방법 :
public string GetAgentTime(double sec)
{
TimeSpan t = TimeSpan.FromSeconds(sec);
return string.Format("{0:D2}h:{1:D2}m:{2:D2}s",
t.Hours,
t.Minutes,
t.Seconds
);
}
아 ... 좋아! 그것에 대해 읽을 필요가 있습니다. 서식을 잊어 버렸습니다. 감사! – InCode