forked from TrueCloudLab/frostfs-node
[#1074] neofs-cli: Move PrettyPrintUnixTime
to the common
package
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
b432558aaa
commit
736e09a70d
3 changed files with 17 additions and 13 deletions
|
@ -2,6 +2,8 @@ package common
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
||||
"github.com/spf13/viper"
|
||||
|
@ -13,3 +15,16 @@ func PrintVerbose(format string, a ...interface{}) {
|
|||
fmt.Printf(format+"\n", a...)
|
||||
}
|
||||
}
|
||||
|
||||
// PrettyPrintUnixTime interprets s as unix timestamp and prints it as
|
||||
// a date. Is s is invalid, "malformed" is returned.
|
||||
func PrettyPrintUnixTime(s string) string {
|
||||
unixTime, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
return "malformed"
|
||||
}
|
||||
|
||||
timestamp := time.Unix(unixTime, 0)
|
||||
|
||||
return timestamp.String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue