this post was submitted on 15 Nov 2024
262 points (93.1% liked)
Programmer Humor
32476 readers
698 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I always hated the implementation for
.toString()
ofDuration
. It gives you a string like that:PT8H6M12.345S
(not a hash)Apparently, it's an ISO 8601 thing, but what the hell am I supposed to do with that?
It's not useful for outputting to end users (which is fair enough), but I don't even want to write that into a log message.
I got so used to this just being garbage that I would automatically call
.toMillis()
and write "ms" after it.Well, and not to gush about Rust too much, but I recently learned that its debug string representation is actually really good. As in, it's better than my Java workaround, because it'll even do things like printing 1000ms as 1s.
And that's just like, oh right, libraries can actually provide a better implementation than what I'll slap down offhandedly.