Skip to content

Allow to skip trailing spaces in humanize.RelTimeΒ #85

Open
@philippgille

Description

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions