i want time duration from failed time to recovery time when i tried recovery time - failed time , its coming exact time in timespan filed . but when its goes into span.Totalminutes the value is change.
var errorPeriod = span != TimeSpan.Zero ? Math.Round(span.TotalMinutes, 2) + " mins" : "Immediately";
i want the exact time .i tried another way
var errorPeriod = span != TimeSpan.Zero ? Math.Max(span.Minutes, 2)+"."+ Math.Max(span.Seconds, 2) + " mins" : "Immediately";
but its subtracts mintues & second diffrent diffrent so i am getting wrong answers
but i am unable to find the right way .
What I have tried:
if (node.ChildNodes.Item(4).InnerText.Equals(""))
{
string failed = node.ChildNodes.Item(9).InnerText;
XmlNodeList nodeList = xmlDoc.GetElementsByTagName("recovered");
string recovered = node.ChildNodes.Item(6).InnerText;
TimeSpan span = (failed != string.Empty && recovered != string.Empty) ? DateTime.Parse(recovered).Subtract(DateTime.Parse(failed)) : TimeSpan.Zero;
var errorPeriod = span != TimeSpan.Zero ? Math.Round(span.TotalMinutes, 2) + " mins" : "Immediately";
var errorPeriod = span != TimeSpan.Zero ? Math.Max(span.Minutes, 2)+"."+ Math.Max(span.Seconds, 2) + " mins" : "Immediately";
sbRecoveryMailBody.AppendFormat("{0}{1}{2}", failed, recovered, errorPeriod, );
}