3
ZioCain
4y

Dear fucking MicroSoft,

I really like the C# language, but the default System types have some little fucks up.

Like, if the DateTime.ToString() accepts "HH" to display hours with leading 0, WHY THE FUCK DOESN'T TimeSpan.ToString()?

Truly yours,
ZioCain

Comments
  • 0
    Because March 23. 00:00 + TimeSpan (4h) = March 23. 03:00 under DST.
  • 3
    And because Datetime is a particular point in time, so the 24 hour clock makes sense. Timespan represents a time period so the 24 hour clock doesn't have meaning.
  • 0
    @nibor ok, but when I have to output that information to a string, wouldn't be useful to have the same formats as DateTime? Just to avoid confusion
  • 3
    @ZioCain an amount of time is not a date.

    You can write your own to string func if you really need it.
  • 1
    Different data structures are different.
    Use something like:

    String myDurationSring =
    string.Format("{0:0000}:{1:00}:{2:00}.{3:00}",
    (int)(ts.TotalHours),
    ts.Minutes,
    ts.Seconds,
    ts.Milliseconds/10.0);
Add Comment