Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to skip trailing spaces in humanize.RelTime #85

Open
philippgille opened this issue Jan 18, 2020 · 0 comments
Open

Allow to skip trailing spaces in humanize.RelTime #85

philippgille opened this issue Jan 18, 2020 · 0 comments

Comments

@philippgille
Copy link

philippgille commented Jan 18, 2020

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?

bigwhoman added a commit to bigwhoman/go-humanize that referenced this issue Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant