• Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    15 hours ago

    I always hated the implementation for .toString() of Duration. 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.