Merge pull request #1365 from rvolosatovs/fix/durations

Truncate sub-{mili,}second durations to 1
This commit is contained in:
Vladimir Mihailenco 2020-06-10 16:43:50 +03:00 committed by GitHub
commit ec194ab8f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -16,9 +16,10 @@ func usePrecise(dur time.Duration) bool {
func formatMs(dur time.Duration) int64 { func formatMs(dur time.Duration) int64 {
if dur > 0 && dur < time.Millisecond { if dur > 0 && dur < time.Millisecond {
internal.Logger.Printf( internal.Logger.Printf(
"specified duration is %s, but minimal supported value is %s", "specified duration is %s, but minimal supported value is %s - truncate to 1",
dur, time.Millisecond, dur, time.Millisecond,
) )
return 1
} }
return int64(dur / time.Millisecond) return int64(dur / time.Millisecond)
} }
@ -26,9 +27,10 @@ func formatMs(dur time.Duration) int64 {
func formatSec(dur time.Duration) int64 { func formatSec(dur time.Duration) int64 {
if dur > 0 && dur < time.Second { if dur > 0 && dur < time.Second {
internal.Logger.Printf( internal.Logger.Printf(
"specified duration is %s, but minimal supported value is %s", "specified duration is %s, but minimal supported value is %s - truncate to 1",
dur, time.Second, dur, time.Second,
) )
return 1
} }
return int64(dur / time.Second) return int64(dur / time.Second)
} }