dustin/go-humanize

Allow to skip trailing spaces in humanize.RelTime

philippgille opened this issue · 0 comments

This is a bit similar to #68, but related to time.

I would love to print something like this:

Your premium subscription expires in 3 weeks.

Trying this one:

fmt.Printf("Your premium subscription expires in %v.\n", username, humanize.RelTime(premiumExpiration, time.Now(), "", ""))

But that becomes:

Your premium subscription expires in 3 weeks .

The reason seem to be the defaultMagnitudes, which are:

var defaultMagnitudes = []RelTimeMagnitude{
	{time.Second, "now", time.Second},
	// ...
	{Month, "%d weeks %s", Week},
	// ...
	{math.MaxInt64, "a long while %s", 1},
}

Do you think it makes sense to change this so that when the blbl parameter is empty, the space is automatically removed?