simonhege/timeago

No suffix/prefix mode?

shazow opened this issue · 2 comments

Would you consider adding a mode that does not include a suffix or prefix?

I want to be able to pass 120 and get "2 hours".

Not sure what the best API would be. I would suggest changing FormatDuration to not include the prefix/suffix, and then having something like FormatAdverb which adds the suffix or prefix.

Thoughts?

What about setting some fields (PastPrefix, PastSuffix, FuturePrefix, FutureSuffix) in a Config to an empty string?
I can add an helper function to do that (as I did for the Max), if you want.
Will it solve your issue?

Actually yes, that works for me. Feel free to close this.

I do feel that it makes more sense for FormatDuration to return a duration. Adding the suffix/prefix is semantically bound to being relative to the current time, so it's not a true duration. But I suppose this is just a nitpick. :)