FuzzyAgoAbbr is an abbreviated version of FuzzyAgo. It returns a human readable string of the time duration between a and b that is estimated to the nearest unit of time.
(a, b time.Time)
| 75 | // FuzzyAgoAbbr is an abbreviated version of FuzzyAgo. It returns a human readable string of the |
| 76 | // time duration between a and b that is estimated to the nearest unit of time. |
| 77 | func FuzzyAgoAbbr(a, b time.Time) string { |
| 78 | ago := a.Sub(b) |
| 79 | |
| 80 | if ago < time.Hour { |
| 81 | return fmt.Sprintf("%d%s", int(ago.Minutes()), "m") |
| 82 | } |
| 83 | if ago < 24*time.Hour { |
| 84 | return fmt.Sprintf("%d%s", int(ago.Hours()), "h") |
| 85 | } |
| 86 | if ago < 30*24*time.Hour { |
| 87 | return fmt.Sprintf("%d%s", int(ago.Hours())/24, "d") |
| 88 | } |
| 89 | |
| 90 | return b.Format("Jan _2, 2006") |
| 91 | } |
| 92 | |
| 93 | // DisplayURL returns a copy of the string urlStr removing everything except the scheme, hostname, and path. |
| 94 | // If the scheme is not specified, "https" is assumed. |