I have a question regarding a character that separates days from hours in TimeSpan.ToString output.
Standard TimeSpan format strings create different delimiter characters:
- "c" creates a period character (".")
- "g" and "G" create a colon character (":")
Example:
// Constant format Console.WriteLine(TimeSpan.FromDays(42).ToString("c", CultureInfo.InvariantCulture)); // Output: 42.00:00:00 (period character between days and hours) // General short format Console.WriteLine(TimeSpan.FromDays(42).ToString("g", CultureInfo.InvariantCulture)); // Output: 42:0:00:00 (colon character between days and hours) // General long format Console.WriteLine(TimeSpan.FromDays(42).ToString("G", CultureInfo.InvariantCulture)); // Output: 42:00:00:00.0000000 (colon character between days and hours)
Does anyone know that this logic is behind it?
However, TimeSpan.Parse successfully parses all of these lines.
Madev source share