Fix removing target charge time (#2066)

This commit is contained in:
andig 2021-12-18 17:15:55 +01:00 • committed by GitHub
parent 5ca18306c4
commit 57f5a72055
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 69 additions and 43 deletions

View file

@ -90,6 +90,12 @@ func NewSocketHub() *SocketHub {
func encode(v interface{}) (string, error) {
var s string
switch val := v.(type) {
case time.Time:
var b []byte
if !val.IsZero() {
b, _ = val.MarshalText()
}
s = fmt.Sprintf(`"%s"`, string(b))
case time.Duration:
// must be before stringer to convert to seconds instead of string
s = fmt.Sprintf("%d", int64(val.Seconds()))