According to MSDN, the d
format specifier outputs the TimeSpan.Days property. When used in the .ToString()
method this appears to be true:
TimeSpan.FromDays(1).ToString("%d")
However, when used in a String.Format
, the specifier throws an exception:
String.Format("{0:d}", TimeSpan.FromDays(1))
'String.Format("{0:d}", TimeSpan.FromDays(1))' threw an exception of type 'System.FormatException'
base {System.SystemException}: {"Input string was not in a correct format."}
The dd
specifier works just fine, but gives a leading zero (as intended).
Why does the d
specifier throw an exception?