Support Unix timestamps for podman logs --since

To match what podman-logs(1) describes --since

Signed-off-by: Chih-Hsuan Yen <yan12125@gmail.com>
This commit is contained in:
Chih-Hsuan Yen
2020-12-04 14:43:34 +08:00
parent 70284b18cc
commit e58fb21ced
2 changed files with 8 additions and 0 deletions

View File

@ -530,6 +530,11 @@ func ParseInputTime(inputTime string) (time.Time, error) {
} }
} }
unix_timestamp, err := strconv.ParseInt(inputTime, 10, 64)
if err == nil {
return time.Unix(unix_timestamp, 0), nil
}
// input might be a duration // input might be a duration
duration, err := time.ParseDuration(inputTime) duration, err := time.ParseDuration(inputTime)
if err != nil { if err != nil {

View File

@ -21,6 +21,9 @@ load helpers
run_podman logs $cid run_podman logs $cid
is "$output" "$rand_string" "output from podman-logs after container is run" is "$output" "$rand_string" "output from podman-logs after container is run"
# test --since with Unix timestamps
run_podman logs --since 1000 $cid
run_podman rm $cid run_podman rm $cid
} }