aboutsummaryrefslogtreecommitdiff
path: root/acid.go
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-01-02 00:35:00 +0100
committerPřemysl Eric Janouch <p@janouch.name>2025-01-02 00:36:03 +0100
commit6622ea0e1cb22687791c26b60381b138cbbb8098 (patch)
tree7b6f626dc92fa91c46f9eb89f54fc464148301b7 /acid.go
parenta492b3b668c1c9be410a7b126550129fba67025a (diff)
downloadacid-6622ea0e1cb22687791c26b60381b138cbbb8098.tar.gz
acid-6622ea0e1cb22687791c26b60381b138cbbb8098.tar.xz
acid-6622ea0e1cb22687791c26b60381b138cbbb8098.zip
Improve formatting of durationsHEADorigin/mastermaster
Since "m" could stand for both "minute" and "month", and months vary in length, let's stop at days.
Diffstat (limited to 'acid.go')
-rw-r--r--acid.go20
1 files changed, 8 insertions, 12 deletions
diff --git a/acid.go b/acid.go
index fd6ce76..9fe9fe4 100644
--- a/acid.go
+++ b/acid.go
@@ -30,7 +30,6 @@ import (
"syscall"
ttemplate "text/template"
"time"
- "unicode"
_ "github.com/mattn/go-sqlite3"
"github.com/pkg/sftp"
@@ -1603,18 +1602,15 @@ func (t *Task) CloneURL() string {
}
func shortDurationString(d time.Duration) string {
- rs := []rune(d.Truncate(time.Second).String())
- for i, r := range rs {
- if !unicode.IsLetter(r) {
- continue
- }
- i++
- for i < len(rs) && unicode.IsLetter(rs[i]) {
- i++
- }
- return string(rs[:i])
+ if d.Abs() >= 24*time.Hour {
+ return strconv.FormatInt(int64(d/time.Hour/24), 10) + "d"
+ } else if d.Abs() >= time.Hour {
+ return strconv.FormatInt(int64(d/time.Hour), 10) + "h"
+ } else if d.Abs() >= time.Minute {
+ return strconv.FormatInt(int64(d/time.Minute), 10) + "m"
+ } else {
+ return strconv.FormatInt(int64(d/time.Second), 10) + "s"
}
- return string(rs)
}
func (t *Task) Created() *time.Time {