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
-
nibor49384yAnd 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.
-
ZioCain27314y@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
-
Quirinus7614y@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);
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