Better datetime display for problems
This commit is contained in:
parent
df714c750b
commit
a985f531ea
26
problem.go
26
problem.go
@ -147,11 +147,29 @@ func ProblemAcknowledge(id int, state bool) (err error) { // {{{
|
|||||||
func (p Problem) FormattedValues() string {
|
func (p Problem) FormattedValues() string {
|
||||||
out := []string{}
|
out := []string{}
|
||||||
for key, val := range p.DatapointValues {
|
for key, val := range p.DatapointValues {
|
||||||
timeVal, ok := val.(time.Time)
|
var keyval string
|
||||||
if ok {
|
|
||||||
logger.Info("FOO", "timeVal", timeVal)
|
switch val.(type) {
|
||||||
|
case int:
|
||||||
|
keyval = fmt.Sprintf("%s: %d", key, val)
|
||||||
|
|
||||||
|
case string:
|
||||||
|
if str, ok := val.(string); ok {
|
||||||
|
timeVal, err := time.Parse(time.RFC3339, str)
|
||||||
|
if err == nil {
|
||||||
|
formattedTime := timeVal.Format("2006-01-02 15:04:05")
|
||||||
|
keyval = fmt.Sprintf("%s: %s", key, formattedTime)
|
||||||
|
} else {
|
||||||
|
keyval = fmt.Sprintf("%s: %s", key, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
keyval = fmt.Sprintf("%s: %v", key, val)
|
||||||
}
|
}
|
||||||
out = append(out, fmt.Sprintf("%s: %v", key, val))
|
|
||||||
|
out = append(out, keyval)
|
||||||
|
|
||||||
}
|
}
|
||||||
sort.Strings(out)
|
sort.Strings(out)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user