From 2dba50741cc4bfce11b8b071b9edf34825c07e3b Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Mon, 13 Jun 2022 13:25:59 +0200 Subject: [PATCH 1/2] common: improve pretty duration regex --- common/format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/format.go b/common/format.go index 6fc21af71923..0607e495acd9 100644 --- a/common/format.go +++ b/common/format.go @@ -27,7 +27,7 @@ import ( // the unnecessary precision off from the formatted textual representation. type PrettyDuration time.Duration -var prettyDurationRe = regexp.MustCompile(`\.[0-9]+`) +var prettyDurationRe = regexp.MustCompile(`\.[0-9]{4,}`) // String implements the Stringer interface, allowing pretty printing of duration // values rounded to three decimals. From af98a6f3147c95cd89ed8cdc78fb5990dc50a516 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 14 Jun 2022 11:34:21 +0200 Subject: [PATCH 2/2] common: improve pretty duration regex --- common/format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/format.go b/common/format.go index 0607e495acd9..7af41f52d540 100644 --- a/common/format.go +++ b/common/format.go @@ -32,7 +32,7 @@ var prettyDurationRe = regexp.MustCompile(`\.[0-9]{4,}`) // String implements the Stringer interface, allowing pretty printing of duration // values rounded to three decimals. func (d PrettyDuration) String() string { - label := fmt.Sprintf("%v", time.Duration(d)) + label := time.Duration(d).String() if match := prettyDurationRe.FindString(label); len(match) > 4 { label = strings.Replace(label, match, match[:4], 1) }