TimeSpan ParseTime (string s)
{
if (s == "" || s == null) throw new RemotingException ("Invalid time value");
int i = s.IndexOfAny (new char[] { 'D','H','M','S' });
string unit;
if (i == -1)
unit = "S";
else {
unit = s.Substring (i);
s = s.Substring (0,i);
}
double val;
try {
val = double.Parse (s);
}
catch {
throw new RemotingException ("Invalid time value: " + s);
}
if (unit == "D") return TimeSpan.FromDays (val);
if (unit == "H") return TimeSpan.FromHours (val);
if (unit == "M") return TimeSpan.FromMinutes (val);
if (unit == "S") return TimeSpan.FromSeconds (val);
if (unit == "MS") return TimeSpan.FromMilliseconds (val);
throw new RemotingException ("Invalid time unit: " + unit);
}