mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-21 08:43:35 +00:00
Pod view is the next level view of managed resource view Signed-off-by: HanMengnan <1448189829@qq.com> Signed-off-by: HanMengnan <1448189829@qq.com>
41 lines
999 B
Go
41 lines
999 B
Go
/*
|
|
Copyright 2022 The KubeVela Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// TimeFormat format time data of `time.Duration` type to string type
|
|
func TimeFormat(t time.Duration) string {
|
|
str := t.String()
|
|
// remove "."
|
|
tmp := strings.Split(str, ".")
|
|
tmp[0] += "s"
|
|
|
|
tmp = strings.Split(tmp[0], "h")
|
|
// hour num
|
|
hour, err := strconv.Atoi(tmp[0])
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return fmt.Sprintf("%dd%dh%2s", hour/24, hour%24, tmp[1])
|
|
}
|