diff options
author | Matej Vasek <mvasek@redhat.com> | 2021-08-04 21:30:47 +0200 |
---|---|---|
committer | Matej Vasek <mvasek@redhat.com> | 2021-08-04 21:30:47 +0200 |
commit | 8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5 (patch) | |
tree | 564c014eb7960b6535fba7ec8ee8efd6030a90ca /pkg/util/utils.go | |
parent | 77f8c6549ab1df393f613cc13e93e8dcec859614 (diff) | |
download | podman-8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5.tar.gz podman-8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5.tar.bz2 podman-8cbbbe6efe5da34da1cdb2c750f4d26e3d306ed5.zip |
Fix TS parsing for fractional values
Parse Unix timestamps that contains fractional part.
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'pkg/util/utils.go')
-rw-r--r-- | pkg/util/utils.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 60aa64ac1..774590f44 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -3,6 +3,7 @@ package util import ( "encoding/json" "fmt" + "math" "os" "os/user" "path/filepath" @@ -530,9 +531,10 @@ func ParseInputTime(inputTime string) (time.Time, error) { } } - unixTimestamp, err := strconv.ParseInt(inputTime, 10, 64) + unixTimestamp, err := strconv.ParseFloat(inputTime, 64) if err == nil { - return time.Unix(unixTimestamp, 0), nil + iPart, fPart := math.Modf(unixTimestamp) + return time.Unix(int64(iPart), int64(fPart*1_000_000_000)).UTC(), nil } // input might be a duration |