Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
nibor48135yAnd 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.
-
ZioCain26675y@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
-
Quirinus7525y@ZioCain an amount of time is not a date.
You can write your own to string func if you really need it. -
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); -
pattercork0103dI'm sorry but the guy that indicate dates + timespan is bogus on certain dates didn't understand the issue. The ToString formatting issue isn't a problem for dates but rather the timespan. And anybody that doesn't understand a timespan of 11:20:30 is 11 hours 20 mins and 30 seconds doesn't understand that that's easier to read (and code) than 11 hours + 20 mins + 30 seconds. Now admittedly you can probably just do TimeSpan.ToString.SubString(0,8) to get an HH:MM:SS representation anyway, but regardless, it would be natural to assume that the ToString function should handle TIME formatting similarly to the way Date.ToString TIME formatting is handled. Is just totally fucking confusing to get an Exception when passing .ToString("HH:mm:ss") params. Just overall laziness on the part of the coder that wrote the ToSting function to not anticipate that time formatting and just say, you know what, fucking don't want to deal with it, so lets throw an exception instead.. Boo, Hiss!
Related Rants
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
rant
microsoft
datetime
date formats
tostring
time formats
c#
timespan