Trim ending whitespaces on timespan pretty print
This commit is contained in:
parent
b2e3b3dec8
commit
7a9c6cec16
|
@ -13,5 +13,20 @@ namespace DeukBot4.Utilities
|
|||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static StringBuilder TrimEnd(this StringBuilder sb)
|
||||
{
|
||||
if (sb == null || sb.Length == 0) return sb;
|
||||
|
||||
int i = sb.Length - 1;
|
||||
for (; i >= 0; i--)
|
||||
if (!char.IsWhiteSpace(sb[i]))
|
||||
break;
|
||||
|
||||
if (i < sb.Length - 1)
|
||||
sb.Length = i + 1;
|
||||
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,8 +40,10 @@ namespace DeukBot4.Utilities
|
|||
sb.AppendFormat("{0} hour{1} ", span.Hours, span.Hours > 1 ? "s" : String.Empty);
|
||||
if (span.Minutes > 0)
|
||||
sb.AppendFormat("{0} minute{1} ", span.Minutes, span.Minutes > 1 ? "s" : String.Empty);
|
||||
sb.TrimEnd();
|
||||
return sb.ToString();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue