-
Notifications
You must be signed in to change notification settings - Fork 233
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 user to define custom time format #25
Comments
How would you specify it? Unless you have a good proposal to do this, it seems like it's be shorter to simply implement what you want yourself in your project, custom for your needs. As an example, I wanted something like |
Also, have you seen |
@shurcooL - Thanks! Accutally I want something like '12s ago' or '21 days'(I don't want to use |
I'd like this as well, seems to be a common mistake that libs like this append "ago". EDIT: just saw the RelTime comment haha. That works. Wouldn't mind having |
Hmm actually on second thought I do think it would be nice, I just got bit by it adding the opinionated "now" for tiny deltas. |
I'll send up a PR in a few minutes. On Wed, Apr 20, 2016 at 5:21 PM TJ Holowaychuk notifications@github.com
|
Sorry, took me a bit more than a couple of minutes to get off the bus, but I think this may do what you want. In particular:
The first one was I think what was being asked for in particular. The second is required because the way it was implemented rounded everything to seconds. The general vision of |
Understandable. I was thinking it could be something like: func Time(t time.Time) string {
if t.Before(time.Now()) {
return Duration(time.Now().Sub(t)) + " ago"
} else {
return Duration(t.Sub(time.Now())) + " from now"
}
} Then if you have a different domain like mine where you'd just like to say "Resolved in X minutes" or similar it's no problem, no |
I guess for my case rounding up or down entire hours etc is not precise enough anyway haha, but hey 😄 |
I'm using go-humanize to format time. But it seems output like '12 seconds ago' is too long for me. So I'm thinking if we can allow users to customize their own output format?
The text was updated successfully, but these errors were encountered: