Skip to content

Instantly share code, notes, and snippets.

@mkropat
Created February 20, 2018 20:00
Show Gist options
  • Save mkropat/380404ccf8f4f280961d978a8bfb104a to your computer and use it in GitHub Desktop.
Save mkropat/380404ccf8f4f280961d978a8bfb104a to your computer and use it in GitHub Desktop.
<Query Kind="Program" />
void Main()
{
Format("00:00:00");
Format("00:00:01");
Format("23:59:00");
Format("24:00:00");
Format("24:00:01");
Format("1.00:00:00");
Format("1.00:00:01");
}
void Format(string format)
{
var t = TimeSpan.Parse(format);
Console.WriteLine($"\"{format}\" = Days: {t.Days}; Hours: {t.Hours}; Minutes: {t.Minutes}; Seconds: {t.Seconds}");
}
// Outputs:
//"00:00:00" = Days: 0; Hours: 0; Minutes: 0; Seconds: 0
//"00:00:01" = Days: 0; Hours: 0; Minutes: 0; Seconds: 1
//"23:59:00" = Days: 0; Hours: 23; Minutes: 59; Seconds: 0
//"24:00:00" = Days: 24; Hours: 0; Minutes: 0; Seconds: 0
//"24:00:01" = Days: 24; Hours: 0; Minutes: 1; Seconds: 0
//"1.00:00:00" = Days: 1; Hours: 0; Minutes: 0; Seconds: 0
//"1.00:00:01" = Days: 1; Hours: 0; Minutes: 0; Seconds: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment